Skip to content

Commit 78ad4d4

Browse files
committed
Merge pull request mozilla#3183 from brendandahl/ignore-bad-dicts
Ignore malformed dictionary entries.
2 parents a87c2da + cec200a commit 78ad4d4

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/parser.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/* globals Ascii85Stream, AsciiHexStream, CCITTFaxStream, Cmd, Dict, error,
1818
FlateStream, isArray, isCmd, isDict, isInt, isName, isNum, isRef,
1919
isString, Jbig2Stream, JpegStream, JpxStream, LZWStream, Name,
20-
NullStream, PredictorStream, Ref, RunLengthStream, warn */
20+
NullStream, PredictorStream, Ref, RunLengthStream, warn, info */
2121

2222
'use strict';
2323

@@ -85,8 +85,11 @@ var Parser = (function ParserClosure() {
8585
this.shift();
8686
var dict = new Dict(this.xref);
8787
while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
88-
if (!isName(this.buf1))
89-
error('Dictionary key must be a name object');
88+
if (!isName(this.buf1)) {
89+
info('Malformed dictionary, key must be a name object');
90+
this.shift();
91+
continue;
92+
}
9093

9194
var key = this.buf1.name;
9295
this.shift();

test/pdfs/bug808084.pdf.link

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf
2+

test/test_manifest.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,14 @@
10511051
"type": "eq",
10521052
"about": "Has a 4 bit per component image with mask and decode."
10531053
},
1054+
{ "id": "bug808084",
1055+
"file": "pdfs/bug808084.pdf",
1056+
"md5": "b1c400de699af29ea3f1983bb26870ab",
1057+
"link": true,
1058+
"rounds": 1,
1059+
"lastPage": 1,
1060+
"type": "load"
1061+
},
10541062
{ "id": "issue3064",
10551063
"file": "pdfs/issue3064.pdf",
10561064
"md5": "0307415b7d69b13acaf8bd4285d9544b",

0 commit comments

Comments
 (0)