Merge pull request #12063 from Snuffleupagus/issue-10989

Tweak the heuristic, in `src/core/jpg.js`, that handles JPEG images with a wildly incorrect SOF (Start of Frame) `scanLines` parameter (issue 10989)
This commit is contained in:
Tim van der Meij 2020-07-11 00:05:11 +02:00 committed by GitHub
commit 7dabc5ecc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View File

@ -163,12 +163,16 @@ var JpegImage = (function JpegImageClosure() {
} else if (nextByte === /* EOI = */ 0xd9) { } else if (nextByte === /* EOI = */ 0xd9) {
if (parseDNLMarker) { if (parseDNLMarker) {
// NOTE: only 8-bit JPEG images are supported in this decoder. // NOTE: only 8-bit JPEG images are supported in this decoder.
const maybeScanLines = blockRow * 8; const maybeScanLines = blockRow * (frame.precision === 8 ? 8 : 0);
// Heuristic to attempt to handle corrupt JPEG images with too // Heuristic to attempt to handle corrupt JPEG images with too
// large `scanLines` parameter, by falling back to the currently // large `scanLines` parameter, by falling back to the currently
// parsed number of scanLines when it's at least one order of // parsed number of scanLines when it's at least (approximately)
// magnitude smaller than expected (fixes issue10880.pdf). // one order of magnitude smaller than expected (fixes
if (maybeScanLines > 0 && maybeScanLines < frame.scanLines / 10) { // issue10880.pdf and issue10989.pdf).
if (
maybeScanLines > 0 &&
Math.round(frame.scanLines / maybeScanLines) >= 10
) {
throw new DNLMarkerError( throw new DNLMarkerError(
"Found EOI marker (0xFFD9) while parsing scan data, " + "Found EOI marker (0xFFD9) while parsing scan data, " +
"possibly caused by incorrect `scanLines` parameter", "possibly caused by incorrect `scanLines` parameter",

View File

@ -0,0 +1 @@
https://github.com/mozilla/pdf.js/files/3410726/ArchitecturalPlanProblemPDF_2.pdf

View File

@ -3746,6 +3746,14 @@
"lastPage": 7, "lastPage": 7,
"type": "eq" "type": "eq"
}, },
{ "id": "issue10989",
"file": "pdfs/issue10989.pdf",
"md5": "c16de154d9ae6dbeec0a113911957efe",
"rounds": 1,
"link": true,
"lastPage": 1,
"type": "eq"
},
{ "id": "issue9650", { "id": "issue9650",
"file": "pdfs/issue9650.pdf", "file": "pdfs/issue9650.pdf",
"md5": "20d50bda6b1080b6d9088811299c791e", "md5": "20d50bda6b1080b6d9088811299c791e",