From f1b0dc6f04ac0c14a9013167b2d8150877a32e17 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 22 Sep 2022 14:04:37 +0200 Subject: [PATCH] Tweak the heuristic that handles JPEG images with a wildly incorrect SOF (Start of Frame) `scanLines` parameter (issue 15492) --- src/core/jpg.js | 6 +++--- test/pdfs/issue15492.pdf.link | 1 + test/test_manifest.json | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 test/pdfs/issue15492.pdf.link diff --git a/src/core/jpg.js b/src/core/jpg.js index 6b53131cc..0bb3dce45 100644 --- a/src/core/jpg.js +++ b/src/core/jpg.js @@ -163,11 +163,11 @@ function decodeScan( // Heuristic to attempt to handle corrupt JPEG images with too // large `scanLines` parameter, by falling back to the currently // parsed number of scanLines when it's at least (approximately) - // one order of magnitude smaller than expected (fixes - // issue10880.pdf and issue10989.pdf). + // one "half" order of magnitude smaller than expected (fixes + // issue10880.pdf, issue10989.pdf, issue15492.pdf). if ( maybeScanLines > 0 && - Math.round(frame.scanLines / maybeScanLines) >= 10 + Math.round(frame.scanLines / maybeScanLines) >= 5 ) { throw new DNLMarkerError( "Found EOI marker (0xFFD9) while parsing scan data, " + diff --git a/test/pdfs/issue15492.pdf.link b/test/pdfs/issue15492.pdf.link new file mode 100644 index 000000000..3dba7ce8e --- /dev/null +++ b/test/pdfs/issue15492.pdf.link @@ -0,0 +1 @@ +https://github.com/mozilla/pdf.js/files/9624549/EP_Kandzetovic.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 83936caa2..e566f083f 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -5166,6 +5166,14 @@ "lastPage": 1, "type": "eq" }, + { "id": "issue15492", + "file": "pdfs/issue15492.pdf", + "md5": "968d36ef340852a4c0e6fa22ced96798", + "rounds": 1, + "link": true, + "lastPage": 1, + "type": "eq" + }, { "id": "issue9650", "file": "pdfs/issue9650.pdf", "md5": "20d50bda6b1080b6d9088811299c791e",