Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support corrupt documents with *empty* Name-entries (issue 13610) #13612

Merged
merged 1 commit into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/core/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,9 @@ class Lexer {
}
if (strBuf.length > 127) {
warn(`Name token is longer than allowed by the spec: ${strBuf.length}`);
} else if (strBuf.length === 0) {
warn("Name token is empty.");
return Name.empty;
}
return Name.get(strBuf.join(""));
}
Expand Down
6 changes: 6 additions & 0 deletions src/core/primitives.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ const Name = (function NameClosure() {
return nameValue ? nameValue : (nameCache[name] = new Name(name));
}

static get empty() {
// eslint-disable-next-line no-restricted-syntax
const emptyName = new Name({ empty: true });
return shadow(this, "empty", emptyName);
}

static _clearCache() {
nameCache = Object.create(null);
}
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/issue13610.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/mozilla/pdf.js/files/6694277/Unitfactuur_18707277_KORTELAND_PRINTEN.INSCANNEN.pdf
7 changes: 7 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,13 @@
"rounds": 1,
"type": "eq"
},
{ "id": "issue13610",
"file": "pdfs/issue13610.pdf",
"md5": "5b894c0b1b2279a245c23abd76648ca9",
"link": true,
"rounds": 1,
"type": "eq"
},
{ "id": "simpletype3font-text",
"file": "pdfs/simpletype3font.pdf",
"md5": "b374c7543920840c61999e9e86939f99",
Expand Down
2 changes: 1 addition & 1 deletion test/unit/evaluator_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ describe("evaluator", function () {
expect(false).toEqual(true);
} catch (reason) {
expect(reason instanceof FormatError).toEqual(true);
expect(reason.message).toEqual("XObject must be referred to by name.");
expect(reason.message).toEqual("XObject should be a stream");
}
});

Expand Down