From ffe462e67eca12a728bf11a2a6f2034e82c2d496 Mon Sep 17 00:00:00 2001 From: m-holger Date: Sat, 27 Jul 2024 16:45:58 +0100 Subject: [PATCH] In ContentNormalizer::handleToken refactor handling of string and name tokens --- libqpdf/ContentNormalizer.cc | 5 +++-- libqpdf/QPDFOutlineDocumentHelper.cc | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libqpdf/ContentNormalizer.cc b/libqpdf/ContentNormalizer.cc index 9da6fa1c..2582e729 100644 --- a/libqpdf/ContentNormalizer.cc +++ b/libqpdf/ContentNormalizer.cc @@ -1,5 +1,6 @@ #include +#include #include ContentNormalizer::ContentNormalizer() : @@ -43,11 +44,11 @@ ContentNormalizer::handleToken(QPDFTokenizer::Token const& token) case QPDFTokenizer::tt_string: // Replacing string and name tokens in this way normalizes their representation as this will // automatically handle quoting of unprintable characters, etc. - writeToken(QPDFTokenizer::Token(QPDFTokenizer::tt_string, token.getValue())); + write(QPDFObjectHandle::newString(token.getValue()).unparse()); break; case QPDFTokenizer::tt_name: - writeToken(QPDFTokenizer::Token(QPDFTokenizer::tt_name, token.getValue())); + write(QPDF_Name::normalizeName(token.getValue())); break; default: diff --git a/libqpdf/QPDFOutlineDocumentHelper.cc b/libqpdf/QPDFOutlineDocumentHelper.cc index dd9db5c1..ba4e4291 100644 --- a/libqpdf/QPDFOutlineDocumentHelper.cc +++ b/libqpdf/QPDFOutlineDocumentHelper.cc @@ -71,7 +71,7 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name) m->dest_dict = qpdf.getRoot().getKey("/Dests"); } QTC::TC("qpdf", "QPDFOutlineDocumentHelper name named dest"); - result= m->dest_dict.getKeyIfDict(name.getName()); + result = m->dest_dict.getKeyIfDict(name.getName()); } else if (name.isString()) { if (!m->names_dest) { auto dests = qpdf.getRoot().getKey("/Names").getKeyIfDict("/Dests");