Avoid truncating inline images, where the data and the "EI" marker is glued together (issue 10388) (#10436)
Thanks to the *excellent* debugging done by @janpe2, this was easy to fix!
This commit is contained in:
parent
eb7cd884ed
commit
b531fc4106
@ -222,7 +222,18 @@ var Parser = (function ParserClosure() {
|
||||
stream.skip(-(stream.pos - maybeEIPos)); // Reset the stream position.
|
||||
}
|
||||
}
|
||||
return ((stream.pos - 4) - startPos);
|
||||
|
||||
let endOffset = 4;
|
||||
stream.skip(-endOffset); // Set the stream position to just before "EI".
|
||||
ch = stream.peekByte();
|
||||
stream.skip(endOffset); // ... and remember to reset the stream position.
|
||||
|
||||
// Ensure that we don't accidentally truncate the inline image, when the
|
||||
// data is immediately followed by the "EI" marker (fixes issue10388.pdf).
|
||||
if (!isSpace(ch)) {
|
||||
endOffset--;
|
||||
}
|
||||
return ((stream.pos - endOffset) - startPos);
|
||||
},
|
||||
/**
|
||||
* Find the EOI (end-of-image) marker 0xFFD9 of the stream.
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -72,6 +72,7 @@
|
||||
!issue9458.pdf
|
||||
!issue9915_reduced.pdf
|
||||
!issue9940.pdf
|
||||
!issue10388_reduced.pdf
|
||||
!issue10438_reduced.pdf
|
||||
!bad-PageLabels.pdf
|
||||
!decodeACSuccessive.pdf
|
||||
|
BIN
test/pdfs/issue10388_reduced.pdf
Normal file
BIN
test/pdfs/issue10388_reduced.pdf
Normal file
Binary file not shown.
@ -739,6 +739,13 @@
|
||||
"link": true,
|
||||
"type": "load"
|
||||
},
|
||||
{ "id": "issue10388",
|
||||
"file": "pdfs/issue10388_reduced.pdf",
|
||||
"md5": "62a6b2adbea1535432bd94a3516e2d4c",
|
||||
"rounds": 1,
|
||||
"link": false,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue7507",
|
||||
"file": "pdfs/issue7507.pdf",
|
||||
"md5": "f7aeaafe0c89b94436e94eaa63307303",
|
||||
|
Loading…
Reference in New Issue
Block a user