From d5e14d3dc33cbbd65f8441551fb4feaf072a0cbd Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 3 Aug 2021 15:50:25 +0200 Subject: [PATCH] Prevent breaking errors when an optional content group is undefined (issue 13851) In the referenced PDF document *most* of the form `/Form` XObjects don't have an `/OC` entry, which thus causes the runtime failure during rendering. --- src/display/optional_content_config.js | 4 ++++ test/pdfs/issue13851.pdf.link | 1 + test/test_manifest.json | 7 +++++++ 3 files changed, 12 insertions(+) create mode 100644 test/pdfs/issue13851.pdf.link diff --git a/src/display/optional_content_config.js b/src/display/optional_content_config.js index 424c3a5c6..b50379efb 100644 --- a/src/display/optional_content_config.js +++ b/src/display/optional_content_config.js @@ -95,6 +95,10 @@ class OptionalContentConfig { } isVisible(group) { + if (!group) { + warn("Optional content group not defined."); + return true; + } if (group.type === "OCG") { if (!this._groups.has(group.id)) { warn(`Optional content group not found: ${group.id}`); diff --git a/test/pdfs/issue13851.pdf.link b/test/pdfs/issue13851.pdf.link new file mode 100644 index 000000000..c035814ac --- /dev/null +++ b/test/pdfs/issue13851.pdf.link @@ -0,0 +1 @@ +https://github.com/mozilla/pdf.js/files/6896539/doc_image.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 9c2325b4c..79c2e0297 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -3688,6 +3688,13 @@ "rounds": 1, "type": "eq" }, + { "id": "issue13851", + "file": "pdfs/issue13851.pdf", + "md5": "d933d397c4efc80faba856bf8deafc1a", + "rounds": 1, + "link": true, + "type": "eq" + }, { "id": "issue1655", "file": "pdfs/issue1655r.pdf", "md5": "569f48449ba57c15c4f9ade151a651c5",