1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #13612 from Snuffleupagus/issue-13610

Support corrupt documents with *empty* `Name`-entries (issue 13610)
This commit is contained in:
Tim van der Meij 2021-06-23 21:49:02 +02:00 committed by GitHub
commit ad4b2ce021
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 1 deletions

View file

@ -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(""));
}

View file

@ -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);
}