Commit 52e024f70198e18c96f613a789baa79622e8f1ea

Authored by Jay Berkenbilt
1 parent cb3b705c

Include omitted object description in error message

ChangeLog
1 2018-02-17 Jay Berkenbilt <ejb@ql.org> 1 2018-02-17 Jay Berkenbilt <ejb@ql.org>
2 2
  3 + * Error message fix: correct some cases in which the object that
  4 + contained a lexical error was omitted from the error message.
  5 +
3 * Error message fix: improve file name in the error message when 6 * Error message fix: improve file name in the error message when
4 there is a parser error inside an object stream. 7 there is a parser error inside an object stream.
5 8
libqpdf/QPDF.cc
@@ -1269,7 +1269,8 @@ QPDF::readObject(PointerHolder&lt;InputSource&gt; input, @@ -1269,7 +1269,8 @@ QPDF::readObject(PointerHolder&lt;InputSource&gt; input,
1269 decrypter = decrypter_ph.getPointer(); 1269 decrypter = decrypter_ph.getPointer();
1270 } 1270 }
1271 QPDFObjectHandle object = QPDFObjectHandle::parse( 1271 QPDFObjectHandle object = QPDFObjectHandle::parse(
1272 - input, description, this->m->tokenizer, empty, decrypter, this); 1272 + input, this->m->last_object_description,
  1273 + this->m->tokenizer, empty, decrypter, this);
1273 if (empty) 1274 if (empty)
1274 { 1275 {
1275 // Nothing in the PDF spec appears to allow empty objects, but 1276 // Nothing in the PDF spec appears to allow empty objects, but
qpdf/qtest/qpdf/eof-reading-token.out
@@ -2,4 +2,4 @@ checking eof-reading-token.pdf @@ -2,4 +2,4 @@ checking eof-reading-token.pdf
2 PDF Version: 1.3 2 PDF Version: 1.3
3 File is not encrypted 3 File is not encrypted
4 File is not linearized 4 File is not linearized
5 -WARNING: eof-reading-token.pdf object stream 12 (file position 5): EOF while reading token 5 +WARNING: eof-reading-token.pdf object stream 12 (object 13 0, file position 5): EOF while reading token
qpdf/qtest/qpdf/indirect-r-arg.out
1 -WARNING: indirect-r-arg.pdf (file position 76): unknown token while reading object; treating as string  
2 -WARNING: indirect-r-arg.pdf (file position 62): expected dictionary key but found non-name object; inserting key /QPDFFake1  
3 -WARNING: indirect-r-arg.pdf (file position 62): expected dictionary key but found non-name object; inserting key /QPDFFake2 1 +WARNING: indirect-r-arg.pdf (object 1 0, file position 76): unknown token while reading object; treating as string
  2 +WARNING: indirect-r-arg.pdf (object 1 0, file position 62): expected dictionary key but found non-name object; inserting key /QPDFFake1
  3 +WARNING: indirect-r-arg.pdf (object 1 0, file position 62): expected dictionary key but found non-name object; inserting key /QPDFFake2
4 checking indirect-r-arg.pdf 4 checking indirect-r-arg.pdf
5 PDF Version: 1.3 5 PDF Version: 1.3
6 File is not encrypted 6 File is not encrypted
qpdf/qtest/qpdf/issue-100.out
1 WARNING: issue-100.pdf: file is damaged 1 WARNING: issue-100.pdf: file is damaged
2 WARNING: issue-100.pdf (file position 736): xref not found 2 WARNING: issue-100.pdf (file position 736): xref not found
3 WARNING: issue-100.pdf: Attempting to reconstruct cross-reference table 3 WARNING: issue-100.pdf: Attempting to reconstruct cross-reference table
4 -WARNING: issue-100.pdf (file position 268): unknown token while reading object; treating as string  
5 -WARNING: issue-100.pdf (file position 286): unknown token while reading object; treating as string  
6 -WARNING: issue-100.pdf (file position 289): unknown token while reading object; treating as string  
7 -WARNING: issue-100.pdf (file position 294): unknown token while reading object; treating as string  
8 -WARNING: issue-100.pdf (file position 297): unknown token while reading object; treating as string  
9 -WARNING: issue-100.pdf (file position 304): unknown token while reading object; treating as string  
10 -WARNING: issue-100.pdf (file position 308): unexpected ) 4 +WARNING: issue-100.pdf (object 5 0, file position 268): unknown token while reading object; treating as string
  5 +WARNING: issue-100.pdf (object 5 0, file position 286): unknown token while reading object; treating as string
  6 +WARNING: issue-100.pdf (object 5 0, file position 289): unknown token while reading object; treating as string
  7 +WARNING: issue-100.pdf (object 5 0, file position 294): unknown token while reading object; treating as string
  8 +WARNING: issue-100.pdf (object 5 0, file position 297): unknown token while reading object; treating as string
  9 +WARNING: issue-100.pdf (object 5 0, file position 304): unknown token while reading object; treating as string
  10 +WARNING: issue-100.pdf (object 5 0, file position 308): unexpected )
11 WARNING: issue-100.pdf (object 5 0, file position 418): /Length key in stream dictionary is not an integer 11 WARNING: issue-100.pdf (object 5 0, file position 418): /Length key in stream dictionary is not an integer
12 WARNING: issue-100.pdf (object 5 0, file position 489): attempting to recover stream length 12 WARNING: issue-100.pdf (object 5 0, file position 489): attempting to recover stream length
13 WARNING: issue-100.pdf (object 5 0, file position 489): recovered stream length: 12 13 WARNING: issue-100.pdf (object 5 0, file position 489): recovered stream length: 12
qpdf/qtest/qpdf/issue-101.out
1 WARNING: issue-101.pdf: file is damaged 1 WARNING: issue-101.pdf: file is damaged
2 WARNING: issue-101.pdf (file position 3526): xref not found 2 WARNING: issue-101.pdf (file position 3526): xref not found
3 WARNING: issue-101.pdf: Attempting to reconstruct cross-reference table 3 WARNING: issue-101.pdf: Attempting to reconstruct cross-reference table
4 -WARNING: issue-101.pdf (file position 1242): expected dictionary key but found non-name object; inserting key /QPDFFake1  
5 -WARNING: issue-101.pdf (file position 1242): dictionary ended prematurely; using null as value for last key 4 +WARNING: issue-101.pdf (object 5 0, file position 1242): expected dictionary key but found non-name object; inserting key /QPDFFake1
  5 +WARNING: issue-101.pdf (object 5 0, file position 1242): dictionary ended prematurely; using null as value for last key
6 WARNING: issue-101.pdf (object 5 0, file position 1438): /Length key in stream dictionary is not an integer 6 WARNING: issue-101.pdf (object 5 0, file position 1438): /Length key in stream dictionary is not an integer
7 WARNING: issue-101.pdf (object 5 0, file position 1509): attempting to recover stream length 7 WARNING: issue-101.pdf (object 5 0, file position 1509): attempting to recover stream length
8 WARNING: issue-101.pdf (object 5 0, file position 1509): recovered stream length: 8 8 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 @@ -32,28 +32,28 @@ WARNING: issue-101.pdf (trailer, file position 3631): recovered stream length: 8
32 WARNING: issue-101.pdf (trailer, file position 4113): /Length key in stream dictionary is not an integer 32 WARNING: issue-101.pdf (trailer, file position 4113): /Length key in stream dictionary is not an integer
33 WARNING: issue-101.pdf (trailer, file position 4184): attempting to recover stream length 33 WARNING: issue-101.pdf (trailer, file position 4184): attempting to recover stream length
34 WARNING: issue-101.pdf (trailer, file position 4184): recovered stream length: 8 34 WARNING: issue-101.pdf (trailer, file position 4184): recovered stream length: 8
35 -WARNING: issue-101.pdf (file position 591): unknown token while reading object; treating as string  
36 -WARNING: issue-101.pdf (file position 625): treating unexpected brace token as null  
37 -WARNING: issue-101.pdf (file position 626): unknown token while reading object; treating as string  
38 -WARNING: issue-101.pdf (file position 637): unknown token while reading object; treating as string  
39 -WARNING: issue-101.pdf (file position 639): unknown token while reading object; treating as string  
40 -WARNING: issue-101.pdf (file position 644): unknown token while reading object; treating as string  
41 -WARNING: issue-101.pdf (file position 647): unknown token while reading object; treating as string  
42 -WARNING: issue-101.pdf (file position 687): unknown token while reading object; treating as string  
43 -WARNING: issue-101.pdf (file position 691): unknown token while reading object; treating as string  
44 -WARNING: issue-101.pdf (file position 696): unknown token while reading object; treating as string  
45 -WARNING: issue-101.pdf (file position 698): unknown token while reading object; treating as string  
46 -WARNING: issue-101.pdf (file position 701): unknown token while reading object; treating as string  
47 -WARNING: issue-101.pdf (file position 711): unknown token while reading object; treating as string  
48 -WARNING: issue-101.pdf (file position 743): unknown token while reading object; treating as string  
49 -WARNING: issue-101.pdf (file position 745): unknown token while reading object; treating as string  
50 -WARNING: issue-101.pdf (file position 747): unknown token while reading object; treating as string  
51 -WARNING: issue-101.pdf (file position 777): unknown token while reading object; treating as string  
52 -WARNING: issue-101.pdf (file position 790): unknown token while reading object; treating as string  
53 -WARNING: issue-101.pdf (file position 800): treating unexpected brace token as null  
54 -WARNING: issue-101.pdf (file position 801): unknown token while reading object; treating as string  
55 -WARNING: issue-101.pdf (file position 811): unknown token while reading object; treating as string  
56 -WARNING: issue-101.pdf (file position 819): unknown token while reading object; treating as string  
57 -WARNING: issue-101.pdf (file position 832): unknown token while reading object; treating as string  
58 -WARNING: issue-101.pdf (file position 856): unexpected > 35 +WARNING: issue-101.pdf (object 11 0, file position 591): unknown token while reading object; treating as string
  36 +WARNING: issue-101.pdf (object 11 0, file position 625): treating unexpected brace token as null
  37 +WARNING: issue-101.pdf (object 11 0, file position 626): unknown token while reading object; treating as string
  38 +WARNING: issue-101.pdf (object 11 0, file position 637): unknown token while reading object; treating as string
  39 +WARNING: issue-101.pdf (object 11 0, file position 639): unknown token while reading object; treating as string
  40 +WARNING: issue-101.pdf (object 11 0, file position 644): unknown token while reading object; treating as string
  41 +WARNING: issue-101.pdf (object 11 0, file position 647): unknown token while reading object; treating as string
  42 +WARNING: issue-101.pdf (object 11 0, file position 687): unknown token while reading object; treating as string
  43 +WARNING: issue-101.pdf (object 11 0, file position 691): unknown token while reading object; treating as string
  44 +WARNING: issue-101.pdf (object 11 0, file position 696): unknown token while reading object; treating as string
  45 +WARNING: issue-101.pdf (object 11 0, file position 698): unknown token while reading object; treating as string
  46 +WARNING: issue-101.pdf (object 11 0, file position 701): unknown token while reading object; treating as string
  47 +WARNING: issue-101.pdf (object 11 0, file position 711): unknown token while reading object; treating as string
  48 +WARNING: issue-101.pdf (object 11 0, file position 743): unknown token while reading object; treating as string
  49 +WARNING: issue-101.pdf (object 11 0, file position 745): unknown token while reading object; treating as string
  50 +WARNING: issue-101.pdf (object 11 0, file position 747): unknown token while reading object; treating as string
  51 +WARNING: issue-101.pdf (object 11 0, file position 777): unknown token while reading object; treating as string
  52 +WARNING: issue-101.pdf (object 11 0, file position 790): unknown token while reading object; treating as string
  53 +WARNING: issue-101.pdf (object 11 0, file position 800): treating unexpected brace token as null
  54 +WARNING: issue-101.pdf (object 11 0, file position 801): unknown token while reading object; treating as string
  55 +WARNING: issue-101.pdf (object 11 0, file position 811): unknown token while reading object; treating as string
  56 +WARNING: issue-101.pdf (object 11 0, file position 819): unknown token while reading object; treating as string
  57 +WARNING: issue-101.pdf (object 11 0, file position 832): unknown token while reading object; treating as string
  58 +WARNING: issue-101.pdf (object 11 0, file position 856): unexpected >
59 issue-101.pdf (file position 856): unable to find /Root dictionary 59 issue-101.pdf (file position 856): unable to find /Root dictionary
qpdf/qtest/qpdf/issue-119.out
1 -WARNING: issue-119.pdf (file position 298): expected dictionary key but found non-name object; inserting key /QPDFFake1  
2 -WARNING: issue-119.pdf (file position 298): expected dictionary key but found non-name object; inserting key /QPDFFake2 1 +WARNING: issue-119.pdf (object 4 0, file position 298): expected dictionary key but found non-name object; inserting key /QPDFFake1
  2 +WARNING: issue-119.pdf (object 4 0, file position 298): expected dictionary key but found non-name object; inserting key /QPDFFake2
3 qpdf: operation succeeded with warnings; resulting file may have some problems 3 qpdf: operation succeeded with warnings; resulting file may have some problems
qpdf/qtest/qpdf/issue-143.out
@@ -6,12 +6,12 @@ WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): recovered s @@ -6,12 +6,12 @@ WARNING: issue-143.pdf (xref stream: object 3 0, file position 654): recovered s
6 WARNING: issue-143.pdf: file is damaged 6 WARNING: issue-143.pdf: file is damaged
7 WARNING: issue-143.pdf (object 1 0, file position 48): expected n n obj 7 WARNING: issue-143.pdf (object 1 0, file position 48): expected n n obj
8 WARNING: issue-143.pdf: Attempting to reconstruct cross-reference table 8 WARNING: issue-143.pdf: Attempting to reconstruct cross-reference table
9 -WARNING: issue-143.pdf (file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake1  
10 -WARNING: issue-143.pdf (file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake2  
11 -WARNING: issue-143.pdf (file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake3  
12 -WARNING: issue-143.pdf (file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake4 9 +WARNING: issue-143.pdf (object 1 0, file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake1
  10 +WARNING: issue-143.pdf (object 1 0, file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake2
  11 +WARNING: issue-143.pdf (object 1 0, file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake3
  12 +WARNING: issue-143.pdf (object 1 0, file position 24): expected dictionary key but found non-name object; inserting key /QPDFFake4
13 WARNING: issue-143.pdf (object 1 0, file position 21): stream dictionary lacks /Length key 13 WARNING: issue-143.pdf (object 1 0, file position 21): stream dictionary lacks /Length key
14 WARNING: issue-143.pdf (object 1 0, file position 84): attempting to recover stream length 14 WARNING: issue-143.pdf (object 1 0, file position 84): attempting to recover stream length
15 WARNING: issue-143.pdf (object 1 0, file position 84): recovered stream length: 606 15 WARNING: issue-143.pdf (object 1 0, file position 84): recovered stream length: 606
16 -WARNING: issue-143.pdf object stream 1 (file position 33): expected dictionary key but found non-name object; inserting key /QPDFFake1 16 +WARNING: issue-143.pdf object stream 1 (object 2 0, file position 33): expected dictionary key but found non-name object; inserting key /QPDFFake1
17 qpdf: operation succeeded with warnings; resulting file may have some problems 17 qpdf: operation succeeded with warnings; resulting file may have some problems