Merge pull request #13612 from Snuffleupagus/issue-13610
Support corrupt documents with *empty* `Name`-entries (issue 13610)
This commit is contained in:
commit
ad4b2ce021
@ -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(""));
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
1
test/pdfs/issue13610.pdf.link
Normal file
1
test/pdfs/issue13610.pdf.link
Normal file
@ -0,0 +1 @@
|
||||
https://github.com/mozilla/pdf.js/files/6694277/Unitfactuur_18707277_KORTELAND_PRINTEN.INSCANNEN.pdf
|
@ -1628,6 +1628,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",
|
||||
|
@ -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");
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user