1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-23 08:38:06 +02:00

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.