Skip to content

Commit

Permalink
Merge pull request #11387 from Snuffleupagus/issue-11385
Browse files Browse the repository at this point in the history
Handle corrupt ASCII85Decode inline images with truncated EOD markers (issue 11385)
  • Loading branch information
timvandermeij authored Dec 8, 2019
2 parents 1677811 + 5c03368 commit a6db045
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ class Parser {
let startPos = stream.pos, ch, length;
while ((ch = stream.getByte()) !== -1) {
if (ch === TILDE) {
const tildePos = stream.pos;

ch = stream.peekByte();
// Handle corrupt PDF documents which contains whitespace "inside" of
// the EOD marker (fixes issue10614.pdf).
Expand All @@ -355,6 +357,14 @@ class Parser {
stream.skip();
break;
}
// Handle corrupt PDF documents which contains truncated EOD markers,
// where the '>' character is missing (fixes issue11385.pdf).
if (stream.pos > tildePos) {
const maybeEI = stream.peekBytes(2);
if (maybeEI[0] === /* E = */ 0x45 && maybeEI[1] === /* I = */ 0x49) {
break;
}
}
}
}
length = stream.pos - startPos;
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/issue11385.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/mozilla/pdf.js/files/3926686/problematic.pdf
8 changes: 8 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,14 @@
"lastPage": 1,
"type": "eq"
},
{ "id": "issue11385",
"file": "pdfs/issue11385.pdf",
"md5": "cc04b23b845366857426a5aa6acf227b",
"rounds": 1,
"link": true,
"lastPage": 1,
"type": "eq"
},
{ "id": "issue6071",
"file": "pdfs/issue6071.pdf",
"md5": "2e08526d8e7c9ba4269fc12ef488d3eb",
Expand Down

0 comments on commit a6db045

Please sign in to comment.