Commit 047bcfcaa605d8a3433bea27a1e82dc0067822c9
1 parent
1dade9a7
treat empty objects as null
git-svn-id: svn+q:///qpdf/trunk@1027 71b93d88-0707-0410-a8cf-f5a4172ac649
Showing
5 changed files
with
111 additions
and
1 deletions
ChangeLog
| 1 | 1 | 2010-09-05 Jay Berkenbilt <ejb@ql.org> |
| 2 | 2 | |
| 3 | + * libqpdf/QPDF.cc (readObjectInternal): Recognize empty objects | |
| 4 | + and treat them as null. | |
| 5 | + | |
| 3 | 6 | * libqpdf/QPDF_Stream.cc (filterable): Handle inline image filter |
| 4 | 7 | abbreviations as stream filter abbreviations. Although this is |
| 5 | 8 | not technically allowed by the PDF specification, table H.1 in the | ... | ... |
libqpdf/QPDF.cc
| ... | ... | @@ -1197,6 +1197,20 @@ QPDF::readObjectInternal(InputSource* input, |
| 1197 | 1197 | olist.pop_back(); |
| 1198 | 1198 | olist.pop_back(); |
| 1199 | 1199 | } |
| 1200 | + else if ((value == "endobj") && | |
| 1201 | + (! (in_array || in_dictionary))) | |
| 1202 | + { | |
| 1203 | + // Nothing in the PDF spec appears to allow empty | |
| 1204 | + // objects, but they have been encountered in | |
| 1205 | + // actual PDF files and Adobe Reader appears to | |
| 1206 | + // ignore them. | |
| 1207 | + warn(QPDFExc(qpdf_e_damaged_pdf, input->getName(), | |
| 1208 | + this->last_object_description, | |
| 1209 | + input->getLastOffset(), | |
| 1210 | + "empty object treated as null")); | |
| 1211 | + object = QPDFObjectHandle::newNull(); | |
| 1212 | + input->seek(input->getLastOffset(), SEEK_SET); | |
| 1213 | + } | |
| 1200 | 1214 | else |
| 1201 | 1215 | { |
| 1202 | 1216 | throw QPDFExc(qpdf_e_damaged_pdf, input->getName(), | ... | ... |
qpdf/qtest/qpdf.test
| ... | ... | @@ -111,7 +111,7 @@ $td->runtest("new stream", |
| 111 | 111 | show_ntests(); |
| 112 | 112 | # ---------- |
| 113 | 113 | $td->notify("--- Miscellaneous Tests ---"); |
| 114 | -$n_tests += 25; | |
| 114 | +$n_tests += 26; | |
| 115 | 115 | |
| 116 | 116 | $td->runtest("qpdf version", |
| 117 | 117 | {$td->COMMAND => "qpdf --version"}, |
| ... | ... | @@ -239,6 +239,12 @@ $td->runtest("check output", |
| 239 | 239 | {$td->FILE => "a.pdf"}, |
| 240 | 240 | {$td->FILE => "filter-abbreviation.out"}); |
| 241 | 241 | |
| 242 | +$td->runtest("empty object", | |
| 243 | + {$td->COMMAND => "qpdf -show-object=7,0 empty-object.pdf"}, | |
| 244 | + {$td->FILE => "empty-object.out", | |
| 245 | + $td->EXIT_STATUS => 3}, | |
| 246 | + $td->NORMALIZE_NEWLINES); | |
| 247 | + | |
| 242 | 248 | show_ntests(); |
| 243 | 249 | # ---------- |
| 244 | 250 | $td->notify("--- Error Condition Tests ---"); | ... | ... |
qpdf/qtest/qpdf/empty-object.out
0 → 100644
qpdf/qtest/qpdf/empty-object.pdf
0 → 100644
| 1 | +%PDF-1.3 | |
| 2 | +1 0 obj | |
| 3 | +<< | |
| 4 | + /Type /Catalog | |
| 5 | + /Pages 2 0 R | |
| 6 | + /X 7 0 R | |
| 7 | +>> | |
| 8 | +endobj | |
| 9 | + | |
| 10 | +2 0 obj | |
| 11 | +<< | |
| 12 | + /Type /Pages | |
| 13 | + /Kids [ | |
| 14 | + 3 0 R | |
| 15 | + ] | |
| 16 | + /Count 1 | |
| 17 | +>> | |
| 18 | +endobj | |
| 19 | + | |
| 20 | +3 0 obj | |
| 21 | +<< | |
| 22 | + /Type /Page | |
| 23 | + /Parent 2 0 R | |
| 24 | + /MediaBox [0 0 612 792] | |
| 25 | + /Contents 4 0 R | |
| 26 | + /Resources << | |
| 27 | + /ProcSet 5 0 R | |
| 28 | + /Font << | |
| 29 | + /F1 6 0 R | |
| 30 | + >> | |
| 31 | + >> | |
| 32 | +>> | |
| 33 | +endobj | |
| 34 | + | |
| 35 | +4 0 obj | |
| 36 | +<< | |
| 37 | + /Length 44 | |
| 38 | +>> | |
| 39 | +stream | |
| 40 | +BT | |
| 41 | + /F1 24 Tf | |
| 42 | + 72 720 Td | |
| 43 | + (Potato) Tj | |
| 44 | +ET | |
| 45 | +endstream | |
| 46 | +endobj | |
| 47 | + | |
| 48 | +5 0 obj | |
| 49 | +[ | |
| 50 | ||
| 51 | + /Text | |
| 52 | +] | |
| 53 | +endobj | |
| 54 | + | |
| 55 | +6 0 obj | |
| 56 | +<< | |
| 57 | + /Type /Font | |
| 58 | + /Subtype /Type1 | |
| 59 | + /Name /F1 | |
| 60 | + /BaseFont /Helvetica | |
| 61 | + /Encoding /WinAnsiEncoding | |
| 62 | +>> | |
| 63 | +endobj | |
| 64 | + | |
| 65 | +7 0 obj | |
| 66 | +endobj | |
| 67 | + | |
| 68 | +xref | |
| 69 | +0 8 | |
| 70 | +0000000000 65535 f | |
| 71 | +0000000009 00000 n | |
| 72 | +0000000074 00000 n | |
| 73 | +0000000146 00000 n | |
| 74 | +0000000318 00000 n | |
| 75 | +0000000414 00000 n | |
| 76 | +0000000449 00000 n | |
| 77 | +0000000567 00000 n | |
| 78 | +trailer << | |
| 79 | + /Size 8 | |
| 80 | + /Root 1 0 R | |
| 81 | +>> | |
| 82 | +startxref | |
| 83 | +583 | |
| 84 | +%%EOF | ... | ... |