From cfcb700eccb886374326462b7f8ff94d9f725d29 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 24 May 2024 21:29:46 +0200 Subject: [PATCH] Prevent XRef errors from breaking font loading (bug 1898802) Note that the referenced file is trivially corrupt, since it contains *two* PDF documents placed in the same file which doesn't make sense (and isn't how a PDF document should be updated). However it's still a good idea to ensure that `loadFont` is able to handle errors when resolving References, since that allows us to invoke the existing fallback font handling. --- src/core/evaluator.js | 6 +++++- test/pdfs/bug1898802.pdf.link | 1 + test/test_manifest.json | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/pdfs/bug1898802.pdf.link diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 8a822954a..1ed1c3749 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -1261,7 +1261,11 @@ class PartialEvaluator { return this.fontCache.get(fontRef); } - font = this.xref.fetchIfRef(fontRef); + try { + font = this.xref.fetchIfRef(fontRef); + } catch (ex) { + warn(`loadFont - lookup failed: "${ex}".`); + } } if (!(font instanceof Dict)) { diff --git a/test/pdfs/bug1898802.pdf.link b/test/pdfs/bug1898802.pdf.link new file mode 100644 index 000000000..791183ee2 --- /dev/null +++ b/test/pdfs/bug1898802.pdf.link @@ -0,0 +1 @@ +https://bugzilla.mozilla.org/attachment.cgi?id=9403877 diff --git a/test/test_manifest.json b/test/test_manifest.json index eb6aceb61..0d9a57e29 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -5447,6 +5447,15 @@ "lastPage": 1, "type": "eq" }, + { + "id": "bug1898802", + "file": "pdfs/bug1898802.pdf", + "md5": "65c3af306253faa8967982812aff523e", + "rounds": 1, + "link": true, + "lastPage": 1, + "type": "eq" + }, { "id": "issue4890", "file": "pdfs/issue4890.pdf",