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:
Jonas Jenwald 2019-01-12 20:31:23 +01:00 committed by Tim van der Meij
parent eb7cd884ed
commit b531fc4106
4 changed files with 20 additions and 1 deletions

View File

@ -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.

View File

@ -72,6 +72,7 @@
!issue9458.pdf
!issue9915_reduced.pdf
!issue9940.pdf
!issue10388_reduced.pdf
!issue10438_reduced.pdf
!bad-PageLabels.pdf
!decodeACSuccessive.pdf

Binary file not shown.

View File

@ -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",