From 52e024f70198e18c96f613a789baa79622e8f1ea Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Fri, 16 Feb 2018 18:34:43 -0500 Subject: [PATCH] Include omitted object description in error message --- ChangeLog | 3 ++ libqpdf/QPDF.cc | 3 +- qpdf/qtest/qpdf/eof-reading-token.out | 2 +- qpdf/qtest/qpdf/indirect-r-arg.out | 6 ++-- qpdf/qtest/qpdf/issue-100.out | 14 ++++---- qpdf/qtest/qpdf/issue-101.out | 52 +++++++++++++-------------- qpdf/qtest/qpdf/issue-119.out | 4 +-- qpdf/qtest/qpdf/issue-143.out | 10 +++--- 8 files changed, 49 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index 119ba0c6..b2efa056 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2018-02-17 Jay Berkenbilt + * Error message fix: correct some cases in which the object that + contained a lexical error was omitted from the error message. + * Error message fix: improve file name in the error message when there is a parser error inside an object stream. diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index 379b34b3..31c8d8e2 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -1269,7 +1269,8 @@ QPDF::readObject(PointerHolder input, decrypter = decrypter_ph.getPointer(); } QPDFObjectHandle object = QPDFObjectHandle::parse( - input, description, this->m->tokenizer, empty, decrypter, this); + input, this->m->last_object_description, + this->m->tokenizer, empty, decrypter, this); if (empty) { // Nothing in the PDF spec appears to allow empty objects, but diff --git a/qpdf/qtest/qpdf/eof-reading-token.out b/qpdf/qtest/qpdf/eof-reading-token.out index fd4fed16..7686803d 100644 --- a/qpdf/qtest/qpdf/eof-reading-token.out +++ b/qpdf/qtest/qpdf/eof-reading-token.out @@ -2,4 +2,4 @@ checking eof-reading-token.pdf PDF Version: 1.3 File is not encrypted File is not linearized -WARNING: eof-reading-token.pdf object stream 12 (file position 5): EOF while reading token +WARNING: eof-reading-token.pdf object stream 12 (object 13 0, file position 5): EOF while reading token diff --git a/qpdf/qtest/qpdf/indirect-r-arg.out b/qpdf/qtest/qpdf/indirect-r-arg.out index e39d8f55..9e33ca52 100644 --- a/qpdf/qtest/qpdf/indirect-r-arg.out +++ b/qpdf/qtest/qpdf/indirect-r-arg.out @@ -1,6 +1,6 @@ -WARNING: indirect-r-arg.pdf (file position 76): unknown token while reading object; treating as string -WARNING: indirect-r-arg.pdf (file position 62): expected dictionary key but found non-name object; inserting key /QPDFFake1 -WARNING: indirect-r-arg.pdf (file position 62): expected dictionary key but found non-name object; inserting key /QPDFFake2 +WARNING: indirect-r-arg.pdf (object 1 0, file position 76): unknown token while reading object; treating as string +WARNING: indirect-r-arg.pdf (object 1 0, file position 62): expected dictionary key but found non-name object; inserting key /QPDFFake1 +WARNING: indirect-r-arg.pdf (object 1 0, file position 62): expected dictionary key but found non-name object; inserting key /QPDFFake2 checking indirect-r-arg.pdf PDF Version: 1.3 File is not encrypted diff --git a/qpdf/qtest/qpdf/issue-100.out b/qpdf/qtest/qpdf/issue-100.out index fbc84369..baa2dccc 100644 --- a/qpdf/qtest/qpdf/issue-100.out +++ b/qpdf/qtest/qpdf/issue-100.out @@ -1,13 +1,13 @@ WARNING: issue-100.pdf: file is damaged WARNING: issue-100.pdf (file position 736): xref not found WARNING: issue-100.pdf: Attempting to reconstruct cross-reference table -WARNING: issue-100.pdf (file position 268): unknown token while reading object; treating as string -WARNING: issue-100.pdf (file position 286): unknown token while reading object; treating as string -WARNING: issue-100.pdf (file position 289): unknown token while reading object; treating as string -WARNING: issue-100.pdf (file position 294): unknown token while reading object; treating as string -WARNING: issue-100.pdf (file position 297): unknown token while reading object; treating as string -WARNING: issue-100.pdf (file position 304): unknown token while reading object; treating as string -WARNING: issue-100.pdf (file position 308): unexpected ) +WARNING: issue-100.pdf (object 5 0, file position 268): unknown token while reading object; treating as string +WARNING: issue-100.pdf (object 5 0, file position 286): unknown token while reading object; treating as string +WARNING: issue-100.pdf (object 5 0, file position 289): unknown token while reading object; treating as string +WARNING: issue-100.pdf (object 5 0, file position 294): unknown token while reading object; treating as string +WARNING: issue-100.pdf (object 5 0, file position 297): unknown token while reading object; treating as string +WARNING: issue-100.pdf (object 5 0, file position 304): unknown token while reading object; treating as string +WARNING: issue-100.pdf (object 5 0, file position 308): unexpected ) WARNING: issue-100.pdf (object 5 0, file position 418): /Length key in stream dictionary is not an integer WARNING: issue-100.pdf (object 5 0, file position 489): attempting to recover stream length WARNING: issue-100.pdf (object 5 0, file position 489): recovered stream length: 12 diff --git a/qpdf/qtest/qpdf/issue-101.out b/qpdf/qtest/qpdf/issue-101.out index b34b0be1..238d5d5f 100644 --- a/qpdf/qtest/qpdf/issue-101.out +++ b/qpdf/qtest/qpdf/issue-101.out @@ -1,8 +1,8 @@ WARNING: issue-101.pdf: file is damaged WARNING: issue-101.pdf (file position 3526): xref not found WARNING: issue-101.pdf: Attempting to reconstruct cross-reference table -WARNING: issue-101.pdf (file position 1242): expected dictionary key but found non-name object; inserting key /QPDFFake1 -WARNING: issue-101.pdf (file position 1242): dictionary ended prematurely; using null as value for last key +WARNING: issue-101.pdf (object 5 0, file position 1242): expected dictionary key but found non-name object; inserting key /QPDFFake1 +WARNING: issue-101.pdf (object 5 0, file position 1242): dictionary ended prematurely; using null as value for last key WARNING: issue-101.pdf (object 5 0, file position 1438): /Length key in stream dictionary is not an integer WARNING: issue-101.pdf (object 5 0, file position 1509): attempting to recover stream length WARNING: issue-101.pdf (object 5 0, file position 1509): recovered stream length: 8 @@ -32,28 +32,28 @@ WARNING: issue-101.pdf (trailer, file position 3631): recovered stream length: 8 WARNING: issue-101.pdf (trailer, file position 4113): /Length key in stream dictionary is not an integer WARNING: issue-101.pdf (trailer, file position 4184): attempting to recover stream length WARNING: issue-101.pdf (trailer, file position 4184): recovered stream length: 8 -WARNING: issue-101.pdf (file position 591): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 625): treating unexpected brace token as null -WARNING: issue-101.pdf (file position 626): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 637): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 639): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 644): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 647): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 687): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 691): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 696): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 698): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 701): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 711): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 743): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 745): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 747): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 777): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 790): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 800): treating unexpected brace token as null -WARNING: issue-101.pdf (file position 801): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 811): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 819): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 832): unknown token while reading object; treating as string -WARNING: issue-101.pdf (file position 856): unexpected > +WARNING: issue-101.pdf (object 11 0, file position 591): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 625): treating unexpected brace token as null +WARNING: issue-101.pdf (object 11 0, file position 626): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 637): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 639): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 644): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 647): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 687): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 691): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 696): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 698): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 701): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 711): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 743): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 745): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 747): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 777): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 790): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 800): treating unexpected brace token as null +WARNING: issue-101.pdf (object 11 0, file position 801): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 811): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 819): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 832): unknown token while reading object; treating as string +WARNING: issue-101.pdf (object 11 0, file position 856): unexpected > issue-101.pdf (file position 856): unable to find /Root dictionary diff --git a/qpdf/qtest/qpdf/issue-119.out b/qpdf/qtest/qpdf/issue-119.out index b83cfe16..37fa4dfb 100644 --- a/qpdf/qtest/qpdf/issue-119.out +++ b/qpdf/qtest/qpdf/issue-119.out @@ -1,3 +1,3 @@ -WARNING: issue-119.pdf (file position 298): expected dictionary key but found non-name object; inserting key /QPDFFake1 -WARNING: issue-119.pdf (file position 298): expected dictionary key but found non-name object; inserting key /QPDFFake2 +WARNING: issue-119.pdf (object 4 0, file position 298): expected dictionary key but found non-name object; inserting key /QPDFFake1 +WARNING: issue-119.pdf (object 4 0, file position 298): expected dictionary key but found non-name object; inserting key /QPDFFake2 qpdf: operation succeeded with warnings; resulting file may have some problems diff --git a/qpdf/qtest/qpdf/issue-143.out b/qpdf/qtest/qpdf/issue-143.out index 376674ae..c7811191 100644 --- a/qpdf/qtest/qpdf/issue-143.out +++ b/qpdf/qtest/qpdf/issue-143.out @@ -6,12 +6,12 @@ WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): recovered s WARNING: issue-143.pdf: file is damaged WARNING: issue-143.pdf (object 1 0, file position 48): expected n n obj WARNING: issue-143.pdf: Attempting to reconstruct cross-reference table -WARNING: issue-143.pdf (file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake1 -WARNING: issue-143.pdf (file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake2 -WARNING: issue-143.pdf (file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake3 -WARNING: issue-143.pdf (file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake4 +WARNING: issue-143.pdf (object 1 0, file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake1 +WARNING: issue-143.pdf (object 1 0, file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake2 +WARNING: issue-143.pdf (object 1 0, file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake3 +WARNING: issue-143.pdf (object 1 0, file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake4 WARNING: issue-143.pdf (object 1 0, file position 21): stream dictionary lacks /Length key WARNING: issue-143.pdf (object 1 0, file position 84): attempting to recover stream length WARNING: issue-143.pdf (object 1 0, file position 84): recovered stream length: 606 -WARNING: issue-143.pdf object stream 1 (file position 33): expected dictionary key but found non-name object; inserting key /QPDFFake1 +WARNING: issue-143.pdf object stream 1 (object 2 0, file position 33): expected dictionary key but found non-name object; inserting key /QPDFFake1 qpdf: operation succeeded with warnings; resulting file may have some problems