From 403d02361726a18ff4a504ca9437b9308c2673e3 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 11 Jul 2024 09:30:42 +0200 Subject: [PATCH] Allow e.g. /FitH destinations without additional parameter (bug 1907000) According to the PDF specification these destinations should have a coordinate parameter, which may however be `null`, but it shouldn't be omitted; please see https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf#G11.2095870 Hence we try to work-around bad PDF generators by making the coordinate parameter optional when validating explicit destinations in both the worker and the viewer. --- src/core/catalog.js | 2 +- test/pdfs/.gitignore | 1 + test/pdfs/bug1907000_reduced.pdf | Bin 0 -> 15392 bytes test/unit/api_spec.js | 43 +++++++++++++++++++++++++++++++ web/pdf_link_service.js | 2 +- 5 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 test/pdfs/bug1907000_reduced.pdf diff --git a/src/core/catalog.js b/src/core/catalog.js index 47d2812de73bb..68db4b847baf2 100644 --- a/src/core/catalog.js +++ b/src/core/catalog.js @@ -78,7 +78,7 @@ function isValidExplicitDest(dest) { case "FitBH": case "FitV": case "FitBV": - if (args.length !== 1) { + if (args.length > 1) { return false; } break; diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 13450e37cd32e..8629cd5bc873f 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -13,6 +13,7 @@ !issue1155r.pdf !issue2017r.pdf !bug1727053.pdf +!bug1907000_reduced.pdf !issue11913.pdf !issue2391-1.pdf !issue2391-2.pdf diff --git a/test/pdfs/bug1907000_reduced.pdf b/test/pdfs/bug1907000_reduced.pdf new file mode 100644 index 0000000000000000000000000000000000000000..60e63076570ba837ee81bc7de8e3f74c9975645c GIT binary patch literal 15392 zcmeHO3vgW3dEUj?QiR7mgfhh<(iwpp7$WU`KNMN1Eu&ztY$J)A1TvJmX)7VlET2tev#NPSs2Y^y$NCY^^M69R8-Bc4bF^vBGH5Xqqz~$-QD12)5OH)5ToB` z!_c;Y!k9>`^Rgp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mFd>TpMLr?Q`>Jz-L`kv13M1fcJS8E z7oOW$-}uiLOw6RWPfgX|cH3Rklgs<>|JJp|Ma{)aiXV9A7e9B8_O&+t;?vtk_Kq}v za^|x~pE!Kvi36?o9X_(>$>z6za-tY}Zs)VpPqlt?&*H|Ph{FetK7HUY=bpWPXVW*I zAL!~zr$4o~b-??^4}S2%OE0%Rb#iqR=6mV*o?V}BJ$~nt`ONaZEn7aa>iQSIe*EY& zPakXHvX4CV@T<+sXxkb}txJFVg-aKochPN!N^1{4_C#^T!6yzq_t=uzN1v=~Io5mc zrO|7$?$TK|_gVPrCuc*>9L zHurnO73YZ*M}GH&BQ5;s6yJ@>kE((YvOkwA;I04tRAz^VuZ_?FpX_#}bjMTG;neW3 zn{*9BPujz}Hk5Mk<%6Cc){@;_UeZh_jbXGpY1Oilx`&^Q8A;rE+9^-B%x->+8h#n* zyN&bVA(F9k@LxQ>Jr-Zqg{Q@YIN%(>BEY%v^Zx+v&Wpt_&|~on&jq{@i(iz&y9;9R z#+86?;kl83ag7+)h;fbQ#?{O4?vhws-4%=L>i~OVad$~9-uYLtxzP)Lx0WwV=NY(} PifK2jSaJ1+-iH4KgWcLw literal 0 HcmV?d00001 diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index 567d02a87de40..5159c166aa296 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -1901,6 +1901,49 @@ describe("api", function () { await loadingTask.destroy(); }); + it("gets outline, with /FitH destinations that lack coordinate parameter (bug 1907000)", async function () { + const loadingTask = getDocument( + buildGetDocumentParams("bug1907000_reduced.pdf") + ); + const pdfDoc = await loadingTask.promise; + const outline = await pdfDoc.getOutline(); + + expect(outline).toEqual([ + { + action: null, + attachment: undefined, + dest: [{ num: 14, gen: 0 }, { name: "FitH" }], + url: null, + unsafeUrl: undefined, + newWindow: undefined, + setOCGState: undefined, + title: "Page 1", + color: new Uint8ClampedArray([0, 0, 0]), + count: undefined, + bold: false, + italic: false, + items: [], + }, + { + action: null, + attachment: undefined, + dest: [{ num: 13, gen: 0 }, { name: "FitH" }], + url: null, + unsafeUrl: undefined, + newWindow: undefined, + setOCGState: undefined, + title: "Page 2", + color: new Uint8ClampedArray([0, 0, 0]), + count: undefined, + bold: false, + italic: false, + items: [], + }, + ]); + + await loadingTask.destroy(); + }); + it("gets non-existent permissions", async function () { const permissions = await pdfDocument.getPermissions(); expect(permissions).toEqual(null); diff --git a/web/pdf_link_service.js b/web/pdf_link_service.js index 7dd8398053ff3..73a29f64b07ef 100644 --- a/web/pdf_link_service.js +++ b/web/pdf_link_service.js @@ -519,7 +519,7 @@ class PDFLinkService { case "FitBH": case "FitV": case "FitBV": - if (args.length !== 1) { + if (args.length > 1) { return false; } break;