From 67af371e587d0ec440c7d3c118841e0fd444eb63 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 19 Sep 2024 21:46:19 +0200 Subject: [PATCH] Ignore non-existing /Shading resources during parsing (issue 18765) --- src/core/evaluator.js | 26 +++++++++++++++++++------- test/pdfs/issue18765.pdf.link | 1 + test/test_manifest.json | 10 ++++++++++ 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 test/pdfs/issue18765.pdf.link diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 6383ad556e6c5..064077fa74aec 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2132,14 +2132,26 @@ class PartialEvaluator { break; case OPS.shadingFill: - var shadingRes = resources.get("Shading"); - if (!shadingRes) { - throw new FormatError("No shading resource found"); - } + let shading; + try { + const shadingRes = resources.get("Shading"); + if (!shadingRes) { + throw new FormatError("No shading resource found"); + } - var shading = shadingRes.get(args[0].name); - if (!shading) { - throw new FormatError("No shading object found"); + shading = shadingRes.get(args[0].name); + if (!shading) { + throw new FormatError("No shading object found"); + } + } catch (reason) { + if (reason instanceof AbortException) { + continue; + } + if (self.options.ignoreErrors) { + warn(`getOperatorList - ignoring Shading: "${reason}".`); + continue; + } + throw reason; } const patternId = self.parseShading({ shading, diff --git a/test/pdfs/issue18765.pdf.link b/test/pdfs/issue18765.pdf.link new file mode 100644 index 0000000000000..5926f09866d92 --- /dev/null +++ b/test/pdfs/issue18765.pdf.link @@ -0,0 +1 @@ +https://github.com/user-attachments/files/17065251/LUCID.-.Asif.Rasha-1.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index c2eb47c18d3b9..9f9b602240da8 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -3021,6 +3021,16 @@ "lastPage": 1, "type": "eq" }, + { + "id": "issue18765", + "file": "pdfs/issue18765.pdf", + "md5": "7763ead2aa69db3a5263f92bb1922e31", + "link": true, + "talos": false, + "rounds": 1, + "lastPage": 1, + "type": "eq" + }, { "id": "issue11139", "file": "pdfs/issue11139.pdf",