mirror of
https://github.com/qpdf/qpdf.git
synced 2024-06-05 03:40:53 +00:00
Accept extraneous space after stream keyword (fixes #329)
This commit is contained in:
parent
43f91f58b8
commit
8a9086a689
|
@ -1,5 +1,8 @@
|
||||||
2019-08-19 Jay Berkenbilt <ejb@ql.org>
|
2019-08-19 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
|
* Accept (and warn for) extraneous whitespace between the stream
|
||||||
|
keyword and newline. Fixes #329.
|
||||||
|
|
||||||
* Properly handle name tokens containing # not preceding two
|
* Properly handle name tokens containing # not preceding two
|
||||||
hexadecimal digits. Such names are invalid in PDF >= 1.2 but valid
|
hexadecimal digits. Such names are invalid in PDF >= 1.2 but valid
|
||||||
in PDF 1.0 and 1.1. Prior to this fix, qpdf's behavior was to
|
in PDF 1.0 and 1.1. Prior to this fix, qpdf's behavior was to
|
||||||
|
|
|
@ -1477,8 +1477,13 @@ QPDF::readObject(PointerHolder<InputSource> input,
|
||||||
// stream data. However, some readers, including
|
// stream data. However, some readers, including
|
||||||
// Adobe reader, accept a carriage return by itself
|
// Adobe reader, accept a carriage return by itself
|
||||||
// when followed by a non-newline character, so that's
|
// when followed by a non-newline character, so that's
|
||||||
// what we do here.
|
// what we do here. We have also seen files that have
|
||||||
|
// extraneous whitespace between the stream keyword and
|
||||||
|
// the newline.
|
||||||
|
bool done = false;
|
||||||
|
while (! done)
|
||||||
{
|
{
|
||||||
|
done = true;
|
||||||
char ch;
|
char ch;
|
||||||
if (input->read(&ch, 1) == 0)
|
if (input->read(&ch, 1) == 0)
|
||||||
{
|
{
|
||||||
|
@ -1519,14 +1524,21 @@ QPDF::readObject(PointerHolder<InputSource> input,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (QUtil::is_space(ch))
|
||||||
|
{
|
||||||
|
warn(QPDFExc(
|
||||||
|
qpdf_e_damaged_pdf,
|
||||||
|
input->getName(),
|
||||||
|
this->m->last_object_description,
|
||||||
|
input->tell(),
|
||||||
|
"stream keyword followed by"
|
||||||
|
" extraneous whitespace"));
|
||||||
|
done = false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QTC::TC("qpdf", "QPDF stream without newline");
|
QTC::TC("qpdf", "QPDF stream without newline");
|
||||||
if (! QUtil::is_space(ch))
|
input->unreadCh(ch);
|
||||||
{
|
|
||||||
QTC::TC("qpdf", "QPDF stream with non-space");
|
|
||||||
input->unreadCh(ch);
|
|
||||||
}
|
|
||||||
warn(QPDFExc(qpdf_e_damaged_pdf, input->getName(),
|
warn(QPDFExc(qpdf_e_damaged_pdf, input->getName(),
|
||||||
this->m->last_object_description,
|
this->m->last_object_description,
|
||||||
input->tell(),
|
input->tell(),
|
||||||
|
|
|
@ -275,7 +275,6 @@ QPDFObjectHandle no val for last key 0
|
||||||
QPDF resolve failure to null 0
|
QPDF resolve failure to null 0
|
||||||
QPDFWriter preserve unreferenced standard 0
|
QPDFWriter preserve unreferenced standard 0
|
||||||
QPDFObjectHandle errors in parsecontent 0
|
QPDFObjectHandle errors in parsecontent 0
|
||||||
QPDF stream with non-space 0
|
|
||||||
qpdf same file error 0
|
qpdf same file error 0
|
||||||
qpdf read args from stdin 0
|
qpdf read args from stdin 0
|
||||||
qpdf read args from file 0
|
qpdf read args from file 0
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
WARNING: stream-line-enders.pdf (object 5 0, offset 384): stream keyword followed by carriage return only
|
WARNING: stream-line-enders.pdf (object 5 0, offset 391): stream keyword followed by carriage return only
|
||||||
WARNING: stream-line-enders.pdf (object 6 0, offset 443): stream keyword not followed by proper line terminator
|
WARNING: stream-line-enders.pdf (object 6 0, offset 450): stream keyword followed by extraneous whitespace
|
||||||
WARNING: stream-line-enders.pdf (object 7 0, offset 503): stream keyword not followed by proper line terminator
|
WARNING: stream-line-enders.pdf (object 6 0, offset 450): stream keyword not followed by proper line terminator
|
||||||
|
WARNING: stream-line-enders.pdf (object 7 0, offset 509): stream keyword not followed by proper line terminator
|
||||||
|
WARNING: stream-line-enders.pdf (object 8 0, offset 567): stream keyword followed by extraneous whitespace
|
||||||
qpdf: operation succeeded with warnings; resulting file may have some problems
|
qpdf: operation succeeded with warnings; resulting file may have some problems
|
||||||
|
|
|
@ -7,7 +7,7 @@ endobj
|
||||||
<< /Count 1 /Kids [ 3 0 R ] /Type /Pages >>
|
<< /Count 1 /Kids [ 3 0 R ] /Type /Pages >>
|
||||||
endobj
|
endobj
|
||||||
3 0 obj
|
3 0 obj
|
||||||
<< /Contents [ 4 0 R 5 0 R 6 0 R 7 0 R ] /MediaBox [ 0 0 612 792 ] /Parent 2 0 R /Resources << /Font << /F1 8 0 R >> /ProcSet 9 0 R >> /Type /Page >>
|
<< /Contents [ 4 0 R 5 0 R 6 0 R 7 0 R 8 0 R ] /MediaBox [ 0 0 612 792 ] /Parent 2 0 R /Resources << /Font << /F1 9 0 R >> /ProcSet 10 0 R >> /Type /Page >>
|
||||||
endobj
|
endobj
|
||||||
4 0 obj
|
4 0 obj
|
||||||
<< /Length 14 >>
|
<< /Length 14 >>
|
||||||
|
@ -27,30 +27,37 @@ stream (Potato) Tj
|
||||||
endstream
|
endstream
|
||||||
endobj
|
endobj
|
||||||
7 0 obj
|
7 0 obj
|
||||||
<< /Length 11 >>
|
<< /Length 9 >>
|
||||||
stream%comment
|
stream%comment
|
||||||
ET
|
|
||||||
endstream
|
endstream
|
||||||
endobj
|
endobj
|
||||||
8 0 obj
|
8 0 obj
|
||||||
<< /BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font >>
|
<< /Length 11 >>
|
||||||
|
stream
|
||||||
|
%comment
|
||||||
|
ET
|
||||||
|
endstream
|
||||||
endobj
|
endobj
|
||||||
9 0 obj
|
9 0 obj
|
||||||
|
<< /BaseFont /Helvetica /Encoding /WinAnsiEncoding /Name /F1 /Subtype /Type1 /Type /Font >>
|
||||||
|
endobj
|
||||||
|
10 0 obj
|
||||||
[ /PDF /Text ]
|
[ /PDF /Text ]
|
||||||
endobj
|
endobj
|
||||||
xref
|
xref
|
||||||
0 10
|
0 11
|
||||||
0000000000 65535 f
|
0000000000 65535 f
|
||||||
0000000015 00000 n
|
0000000015 00000 n
|
||||||
0000000064 00000 n
|
0000000064 00000 n
|
||||||
0000000123 00000 n
|
0000000123 00000 n
|
||||||
0000000288 00000 n
|
0000000295 00000 n
|
||||||
0000000352 00000 n
|
0000000359 00000 n
|
||||||
0000000411 00000 n
|
0000000418 00000 n
|
||||||
0000000472 00000 n
|
0000000479 00000 n
|
||||||
0000000532 00000 n
|
0000000535 00000 n
|
||||||
0000000639 00000 n
|
0000000598 00000 n
|
||||||
trailer << /Root 1 0 R /Size 10 /ID [<08aa98c73f8a7262d77c8328772c3989><5a35fde138b2e8251b9e079b560c0253>] >>
|
0000000705 00000 n
|
||||||
|
trailer << /Root 1 0 R /Size 11 /ID [<08aa98c73f8a7262d77c8328772c3989><5a35fde138b2e8251b9e079b560c0253>] >>
|
||||||
startxref
|
startxref
|
||||||
669
|
736
|
||||||
%%EOF
|
%%EOF
|
||||||
|
|
|
@ -30,6 +30,7 @@ endobj
|
||||||
6 0 R
|
6 0 R
|
||||||
8 0 R
|
8 0 R
|
||||||
10 0 R
|
10 0 R
|
||||||
|
12 0 R
|
||||||
]
|
]
|
||||||
/MediaBox [
|
/MediaBox [
|
||||||
0
|
0
|
||||||
|
@ -40,9 +41,9 @@ endobj
|
||||||
/Parent 2 0 R
|
/Parent 2 0 R
|
||||||
/Resources <<
|
/Resources <<
|
||||||
/Font <<
|
/Font <<
|
||||||
/F1 12 0 R
|
/F1 14 0 R
|
||||||
>>
|
>>
|
||||||
/ProcSet 13 0 R
|
/ProcSet 15 0 R
|
||||||
>>
|
>>
|
||||||
/Type /Page
|
/Type /Page
|
||||||
>>
|
>>
|
||||||
|
@ -102,17 +103,32 @@ endobj
|
||||||
>>
|
>>
|
||||||
stream
|
stream
|
||||||
%comment
|
%comment
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
|
||||||
|
11 0 obj
|
||||||
|
9
|
||||||
|
endobj
|
||||||
|
|
||||||
|
%% Contents for page 1
|
||||||
|
%% Original object ID: 8 0
|
||||||
|
12 0 obj
|
||||||
|
<<
|
||||||
|
/Length 13 0 R
|
||||||
|
>>
|
||||||
|
stream
|
||||||
|
%comment
|
||||||
ET
|
ET
|
||||||
endstream
|
endstream
|
||||||
endobj
|
endobj
|
||||||
|
|
||||||
%QDF: ignore_newline
|
%QDF: ignore_newline
|
||||||
11 0 obj
|
13 0 obj
|
||||||
11
|
11
|
||||||
endobj
|
endobj
|
||||||
|
|
||||||
%% Original object ID: 8 0
|
%% Original object ID: 9 0
|
||||||
12 0 obj
|
14 0 obj
|
||||||
<<
|
<<
|
||||||
/BaseFont /Helvetica
|
/BaseFont /Helvetica
|
||||||
/Encoding /WinAnsiEncoding
|
/Encoding /WinAnsiEncoding
|
||||||
|
@ -122,8 +138,8 @@ endobj
|
||||||
>>
|
>>
|
||||||
endobj
|
endobj
|
||||||
|
|
||||||
%% Original object ID: 9 0
|
%% Original object ID: 10 0
|
||||||
13 0 obj
|
15 0 obj
|
||||||
[
|
[
|
||||||
/PDF
|
/PDF
|
||||||
/Text
|
/Text
|
||||||
|
@ -131,26 +147,28 @@ endobj
|
||||||
endobj
|
endobj
|
||||||
|
|
||||||
xref
|
xref
|
||||||
0 14
|
0 16
|
||||||
0000000000 65535 f
|
0000000000 65535 f
|
||||||
0000000052 00000 n
|
0000000052 00000 n
|
||||||
0000000133 00000 n
|
0000000133 00000 n
|
||||||
0000000242 00000 n
|
0000000242 00000 n
|
||||||
0000000527 00000 n
|
0000000538 00000 n
|
||||||
0000000596 00000 n
|
0000000607 00000 n
|
||||||
0000000665 00000 n
|
0000000676 00000 n
|
||||||
0000000730 00000 n
|
0000000741 00000 n
|
||||||
0000000799 00000 n
|
0000000810 00000 n
|
||||||
0000000866 00000 n
|
0000000877 00000 n
|
||||||
0000000935 00000 n
|
0000000946 00000 n
|
||||||
0000001025 00000 n
|
0000001012 00000 n
|
||||||
0000001072 00000 n
|
0000001081 00000 n
|
||||||
|
0000001171 00000 n
|
||||||
0000001218 00000 n
|
0000001218 00000 n
|
||||||
|
0000001365 00000 n
|
||||||
trailer <<
|
trailer <<
|
||||||
/Root 1 0 R
|
/Root 1 0 R
|
||||||
/Size 14
|
/Size 16
|
||||||
/ID [<08aa98c73f8a7262d77c8328772c3989><31415926535897932384626433832795>]
|
/ID [<08aa98c73f8a7262d77c8328772c3989><31415926535897932384626433832795>]
|
||||||
>>
|
>>
|
||||||
startxref
|
startxref
|
||||||
1254
|
1401
|
||||||
%%EOF
|
%%EOF
|
||||||
|
|
Loading…
Reference in New Issue
Block a user