2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-03 19:00:51 +00:00

treat empty objects as null

git-svn-id: svn+q:///qpdf/trunk@1027 71b93d88-0707-0410-a8cf-f5a4172ac649
This commit is contained in:
Jay Berkenbilt 2010-09-06 02:17:55 +00:00
parent 1dade9a7ee
commit 047bcfcaa6
5 changed files with 111 additions and 1 deletions

View File

@ -1,5 +1,8 @@
2010-09-05 Jay Berkenbilt <ejb@ql.org> 2010-09-05 Jay Berkenbilt <ejb@ql.org>
* libqpdf/QPDF.cc (readObjectInternal): Recognize empty objects
and treat them as null.
* libqpdf/QPDF_Stream.cc (filterable): Handle inline image filter * libqpdf/QPDF_Stream.cc (filterable): Handle inline image filter
abbreviations as stream filter abbreviations. Although this is abbreviations as stream filter abbreviations. Although this is
not technically allowed by the PDF specification, table H.1 in the not technically allowed by the PDF specification, table H.1 in the

View File

@ -1197,6 +1197,20 @@ QPDF::readObjectInternal(InputSource* input,
olist.pop_back(); olist.pop_back();
olist.pop_back(); olist.pop_back();
} }
else if ((value == "endobj") &&
(! (in_array || in_dictionary)))
{
// Nothing in the PDF spec appears to allow empty
// objects, but they have been encountered in
// actual PDF files and Adobe Reader appears to
// ignore them.
warn(QPDFExc(qpdf_e_damaged_pdf, input->getName(),
this->last_object_description,
input->getLastOffset(),
"empty object treated as null"));
object = QPDFObjectHandle::newNull();
input->seek(input->getLastOffset(), SEEK_SET);
}
else else
{ {
throw QPDFExc(qpdf_e_damaged_pdf, input->getName(), throw QPDFExc(qpdf_e_damaged_pdf, input->getName(),

View File

@ -111,7 +111,7 @@ $td->runtest("new stream",
show_ntests(); show_ntests();
# ---------- # ----------
$td->notify("--- Miscellaneous Tests ---"); $td->notify("--- Miscellaneous Tests ---");
$n_tests += 25; $n_tests += 26;
$td->runtest("qpdf version", $td->runtest("qpdf version",
{$td->COMMAND => "qpdf --version"}, {$td->COMMAND => "qpdf --version"},
@ -239,6 +239,12 @@ $td->runtest("check output",
{$td->FILE => "a.pdf"}, {$td->FILE => "a.pdf"},
{$td->FILE => "filter-abbreviation.out"}); {$td->FILE => "filter-abbreviation.out"});
$td->runtest("empty object",
{$td->COMMAND => "qpdf -show-object=7,0 empty-object.pdf"},
{$td->FILE => "empty-object.out",
$td->EXIT_STATUS => 3},
$td->NORMALIZE_NEWLINES);
show_ntests(); show_ntests();
# ---------- # ----------
$td->notify("--- Error Condition Tests ---"); $td->notify("--- Error Condition Tests ---");

View File

@ -0,0 +1,3 @@
WARNING: empty-object.pdf (object 7 0, file position 575): empty object treated as null
null
qpdf: operation succeeded with warnings; resulting file may have some problems

View File

@ -0,0 +1,84 @@
%PDF-1.3
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
/X 7 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/Kids [
3 0 R
]
/Count 1
>>
endobj
3 0 obj
<<
/Type /Page
/Parent 2 0 R
/MediaBox [0 0 612 792]
/Contents 4 0 R
/Resources <<
/ProcSet 5 0 R
/Font <<
/F1 6 0 R
>>
>>
>>
endobj
4 0 obj
<<
/Length 44
>>
stream
BT
/F1 24 Tf
72 720 Td
(Potato) Tj
ET
endstream
endobj
5 0 obj
[
/PDF
/Text
]
endobj
6 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Helvetica
/Encoding /WinAnsiEncoding
>>
endobj
7 0 obj
endobj
xref
0 8
0000000000 65535 f
0000000009 00000 n
0000000074 00000 n
0000000146 00000 n
0000000318 00000 n
0000000414 00000 n
0000000449 00000 n
0000000567 00000 n
trailer <<
/Size 8
/Root 1 0 R
>>
startxref
583
%%EOF