diff --git a/src/core/parser.js b/src/core/parser.js index 176884296..010e9152a 100644 --- a/src/core/parser.js +++ b/src/core/parser.js @@ -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). @@ -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; diff --git a/test/pdfs/issue11385.pdf.link b/test/pdfs/issue11385.pdf.link new file mode 100644 index 000000000..7a3cd2c00 --- /dev/null +++ b/test/pdfs/issue11385.pdf.link @@ -0,0 +1 @@ +https://github.com/mozilla/pdf.js/files/3926686/problematic.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index f8a7badbe..1bd45a6d1 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -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",