From bc13a277ce6e49fd11776f3fa7f41dbee7f2c37a Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 19 Oct 2022 12:28:25 +0200 Subject: [PATCH] Relax the /Pages dictionary /Count check for corrupt documents (issue 9105) After PR 14311, and follow-up patches, we no longer require that the /Count entry (in the /Pages dictionary) is either present or even valid in order to parse/render a PDF document. Hence it seems strange to keep this requirement for *corrupt* PDF documents, when trying to find a usable `trailer` in the `XRef.indexObjects` method. --- src/core/xref.js | 4 ---- test/pdfs/.gitignore | 1 + test/pdfs/issue9105_other.pdf | 14 ++++++++++++++ test/test_manifest.json | 7 +++++++ 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 test/pdfs/issue9105_other.pdf diff --git a/src/core/xref.js b/src/core/xref.js index dcbd49307..d75b899b9 100644 --- a/src/core/xref.js +++ b/src/core/xref.js @@ -591,10 +591,6 @@ class XRef { if (!(pagesDict instanceof Dict)) { continue; } - const pagesCount = pagesDict.get("Count"); - if (!Number.isInteger(pagesCount)) { - continue; - } // The top-level /Pages dictionary isn't obviously corrupt. } catch (ex) { trailerError = ex; diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 047f06317..9d25fd4f7 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -94,6 +94,7 @@ !issue9084.pdf !issue12963.pdf !issue9105_reduced.pdf +!issue9105_other.pdf !issue9252.pdf !issue9262_reduced.pdf !issue9291.pdf diff --git a/test/pdfs/issue9105_other.pdf b/test/pdfs/issue9105_other.pdf new file mode 100644 index 000000000..513713df9 --- /dev/null +++ b/test/pdfs/issue9105_other.pdf @@ -0,0 +1,14 @@ +%PDF-1. +1 0 obj +<>]/Resources<<>>>> +2 0 obj +<<>> +stream +BT +/F1 105 Tf +0 400 Td +(Adobe tweet) Tj +ET +endstream +endobj +trailer<>>> \ No newline at end of file diff --git a/test/test_manifest.json b/test/test_manifest.json index aa7368805..ae251db11 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1748,6 +1748,13 @@ "link": false, "type": "eq" }, + { "id": "issue9105_other", + "file": "pdfs/issue9105_other.pdf", + "md5": "4c8b9c2cceb9c5d621e1d50b3dc38efc", + "rounds": 1, + "link": false, + "type": "eq" + }, { "id": "issue269_1", "file": "pdfs/issue269_1.pdf", "md5": "ab932f697b4d2e2bf700de15a8efea9c",