1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #10615 from Snuffleupagus/corrupt-inline-ASCII85Decode

Handle corrupt ASCII85Decode inline images with whitespace "inside" of the EOD marker (issue 10614)
This commit is contained in:
Tim van der Meij 2019-03-08 23:06:01 +01:00 committed by GitHub
commit 8b149b818e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 5 deletions

View file

@ -336,14 +336,22 @@ var Parser = (function ParserClosure() {
* Find the EOD (end-of-data) marker '~>' (i.e. TILDE + GT) of the stream.
* @returns {number} The inline stream length.
*/
findASCII85DecodeInlineStreamEnd:
function Parser_findASCII85DecodeInlineStreamEnd(stream) {
findASCII85DecodeInlineStreamEnd(stream) {
var TILDE = 0x7E, GT = 0x3E;
var startPos = stream.pos, ch, length;
while ((ch = stream.getByte()) !== -1) {
if (ch === TILDE && stream.peekByte() === GT) {
stream.skip();
break;
if (ch === TILDE) {
ch = stream.peekByte();
// Handle corrupt PDF documents which contains whitespace "inside" of
// the EOD marker (fixes issue10614.pdf).
while (isSpace(ch)) {
stream.skip();
ch = stream.peekByte();
}
if (ch === GT) {
stream.skip();
break;
}
}
}
length = stream.pos - startPos;