From 935568c2f1d395a0a92df60365bc96a45e3d26cc Mon Sep 17 00:00:00 2001 From: Jani Pehkonen Date: Mon, 5 Oct 2020 17:38:01 +0300 Subject: [PATCH] Fix invalid `XUID` entries in CFF fonts In CFF fonts, entry `XUID` should be an array that has no more than 16 elements. In the issue, the length is 20, which causes the fonts to fail. See Appendix B, "Implementation Limits" in PostScript Language Reference Manual https://web.archive.org/web/20170218093716/https://www.adobe.com/products/postscript/pdfs/PLRM.pdf Actually entries `XUID` and `UniqueID` are obsolete altogether. https://blogs.adobe.com/CCJKType/2016/06/no-more-xuid-arrays.html --- src/core/cff_parser.js | 6 ++++++ test/pdfs/.gitignore | 1 + test/pdfs/issue12399_reduced.pdf | Bin 0 -> 7552 bytes test/test_manifest.json | 6 ++++++ 4 files changed, 13 insertions(+) create mode 100644 test/pdfs/issue12399_reduced.pdf diff --git a/src/core/cff_parser.js b/src/core/cff_parser.js index 540972e9e4f6e..d4b67901b79c6 100644 --- a/src/core/cff_parser.js +++ b/src/core/cff_parser.js @@ -1407,6 +1407,12 @@ class CFFCompiler { } } + const xuid = cff.topDict.getByName("XUID"); + if (xuid && xuid.length > 16) { + // Length of XUID array must not be greater than 16 (issue #12399). + cff.topDict.removeByName("XUID"); + } + cff.topDict.setByName("charset", 0); var compiled = this.compileTopDicts( [cff.topDict], diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 33b9df646d6c5..cadb2e9f3c3fe 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -169,6 +169,7 @@ !issue5202.pdf !images_1bit_grayscale.pdf !issue5280.pdf +!issue12399_reduced.pdf !issue5677.pdf !issue5954.pdf !issue6612.pdf diff --git a/test/pdfs/issue12399_reduced.pdf b/test/pdfs/issue12399_reduced.pdf new file mode 100644 index 0000000000000000000000000000000000000000..10241c031e4f22b94759e4f8b102397cbc23f221 GIT binary patch literal 7552 zcmaKR2|U!@_i#uuC0mpwjgT$A#xjPo?>j^GZ7>)y!_3$t`@TKNmM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