From 48a76aea2b9fe85aa003831b31361c7f1598c184 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 18 Dec 2020 15:42:28 +0100 Subject: [PATCH] Ignore, rather than throwing on, Coding style component (COC) markers in JPEG 2000 images (issue 12752) Similar to other markers that we currently skip, by ignoring the Coding style component (COC) marker we'll at least prevent outright errors (although some JPEG 2000 images may look slightly wrong). --- src/core/jpx.js | 7 +++---- test/pdfs/issue12752.pdf.link | 1 + test/test_manifest.json | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 test/pdfs/issue12752.pdf.link diff --git a/src/core/jpx.js b/src/core/jpx.js index 4269338c2..d6583ff99 100644 --- a/src/core/jpx.js +++ b/src/core/jpx.js @@ -392,6 +392,9 @@ var JpxImage = (function JpxImageClosure() { length = tile.dataEnd - position; parseTilePackets(context, data, position, length); break; + case 0xff53: // Coding style component (COC) + warn("JPX: Codestream code 0xFF53 (COC) is not implemented."); + /* falls through */ case 0xff55: // Tile-part lengths, main header (TLM) case 0xff57: // Packet length, main header (PLM) case 0xff58: // Packet length, tile-part header (PLT) @@ -399,10 +402,6 @@ var JpxImage = (function JpxImageClosure() { length = readUint16(data, position); // skipping content break; - case 0xff53: // Coding style component (COC) - throw new Error( - "Codestream code 0xFF53 (COC) is not implemented" - ); default: throw new Error("Unknown codestream code: " + code.toString(16)); } diff --git a/test/pdfs/issue12752.pdf.link b/test/pdfs/issue12752.pdf.link new file mode 100644 index 000000000..f3e2fc0ee --- /dev/null +++ b/test/pdfs/issue12752.pdf.link @@ -0,0 +1 @@ +https://github.com/mozilla/pdf.js/files/5715933/WE2330Ausweis_2.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 1fd7bfa1d..ccfdaa602 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -2045,6 +2045,14 @@ "link": true, "type": "eq" }, + { "id": "issue12752", + "file": "pdfs/issue12752.pdf", + "md5": "9f8ada17a613d18919714baf684e165f", + "rounds": 1, + "lastPage": 1, + "link": true, + "type": "eq" + }, { "id": "issue7872", "file": "pdfs/issue7872.pdf", "md5": "81781dfecfcb7e9cd9cc7e60f8b747b7",