Skip to content

Commit

Permalink
Ignore invalid /Encoding-entries when parsing fonts (issue 14821)
Browse files Browse the repository at this point in the history
In the referenced PDF document the fonts have /Encoding-entries that are Streams (containing completely bogus data), which are thus obviously not valid here.
Hence, only when `ignoreErrors` is set, we'll now ignore these corrupt /Encoding-entries and fallback to the existing code to try and infer a usable encoding.

Given that this is *clearly* a case of corrupt PDF documents, there's no guarantee that this will "fix" all such cases, however it's the best that we do here and shouldn't really be worse than ignoring an entire font.
  • Loading branch information
Snuffleupagus committed Apr 22, 2022
1 parent 452a98b commit e723da7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3405,7 +3405,12 @@ class PartialEvaluator {
} else if (encoding instanceof Name) {
baseEncodingName = encoding.name;
} else {
throw new FormatError("Encoding is not a Name nor a Dict");
const msg = "Encoding is not a Name nor a Dict";

if (!this.options.ignoreErrors) {
throw new FormatError(msg);
}
warn(msg);
}
// According to table 114 if the encoding is a named encoding it must be
// one of these predefined encodings.
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
!asciihexdecode.pdf
!bug766086.pdf
!bug793632.pdf
!issue14821.pdf
!bug1020858.pdf
!prefilled_f1040.pdf
!bug1050040.pdf
Expand Down
Binary file added test/pdfs/issue14821.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3612,6 +3612,12 @@
"rounds": 1,
"type": "eq"
},
{ "id": "issue14821",
"file": "pdfs/issue14821.pdf",
"md5": "ae77afb0f98c62e6b7fe7f912c84a75c",
"rounds": 1,
"type": "eq"
},
{
"id": "issue6165",
"file": "pdfs/issue6165.pdf",
Expand Down

0 comments on commit e723da7

Please sign in to comment.