aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFTokenizer.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2023-10-14 23:04:58 +0200
committerJay Berkenbilt <ejb@ql.org>2023-10-14 23:12:56 +0200
commit1ecc6bb29e24a4f89470ff91b2682b46e0576ad4 (patch)
treeea1b53013bb0f8887eb28f5862afa57db30d34e8 /libqpdf/QPDFTokenizer.cc
parent467e5d6226d6b609069d7703cd1edc1552aa62bc (diff)
downloadqpdf-1ecc6bb29e24a4f89470ff91b2682b46e0576ad4.tar.zst
Don't lose character after \d or \dd parsing string (fixes #1050)
Diffstat (limited to 'libqpdf/QPDFTokenizer.cc')
-rw-r--r--libqpdf/QPDFTokenizer.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/libqpdf/QPDFTokenizer.cc b/libqpdf/QPDFTokenizer.cc
index d98af8a9..ca09708a 100644
--- a/libqpdf/QPDFTokenizer.cc
+++ b/libqpdf/QPDFTokenizer.cc
@@ -145,9 +145,8 @@ QPDFTokenizer::presentCharacter(char ch)
void
QPDFTokenizer::handleCharacter(char ch)
{
- // State machine is implemented such that the final character may not be handled. This happens
- // whenever you have to use a character from the next token to detect the end of the current
- // token.
+ // In some cases, functions called below may call a second handler. This happens whenever you
+ // have to use a character from the next token to detect the end of the current token.
switch (this->state) {
case st_top:
@@ -692,16 +691,21 @@ QPDFTokenizer::inHexstring2nd(char ch)
void
QPDFTokenizer::inCharCode(char ch)
{
+ bool handled = false;
if (('0' <= ch) && (ch <= '7')) {
this->char_code = 8 * this->char_code + (int(ch) - int('0'));
if (++(this->digit_count) < 3) {
return;
}
- // We've accumulated \ddd. PDF Spec says to ignore high-order overflow.
+ handled = true;
}
+ // We've accumulated \ddd or we have \d or \dd followed by other than an octal digit. The PDF
+ // Spec says to ignore high-order overflow.
this->val += char(this->char_code % 256);
this->state = st_in_string;
- return;
+ if (!handled) {
+ inString(ch);
+ }
}
void