Take the W array into account when computing the hash, in PartialEvaluator.preEvaluateFont, for composite fonts (issue 13343)

Without this some *composite* fonts may incorrectly end up with matching `hash`es, thus breaking rendering since we'll not actually try to load/parse some of the fonts.

*Please note:* Given that the document, in the referenced issue, doesn't embed *any* of its fonts there's no guarantee that it renders correctly in all configurations even with this patch.
This commit is contained in:
Jonas Jenwald 2021-05-07 11:49:58 +02:00
parent a2652bafd9
commit fc59a5f709
4 changed files with 28 additions and 0 deletions

View File

@ -3620,6 +3620,27 @@ class PartialEvaluator {
uint8array = new Uint8Array(new Uint32Array(widths).buffer);
hash.update(uint8array);
}
if (composite) {
const compositeWidths = dict.get("W") || baseDict.get("W");
if (Array.isArray(compositeWidths)) {
const widthsBuf = [];
for (const entry of compositeWidths) {
if (isNum(entry) || isRef(entry)) {
widthsBuf.push(entry.toString());
} else if (Array.isArray(entry)) {
const subWidthsBuf = [];
for (const element of entry) {
if (isNum(element) || isRef(element)) {
subWidthsBuf.push(element.toString());
}
}
widthsBuf.push(`[${subWidthsBuf.join()}]`);
}
}
hash.update(widthsBuf.join());
}
}
}
return {

View File

@ -313,6 +313,7 @@
!noembed-eucjp.pdf
!noembed-sjis.pdf
!vertical.pdf
!issue13343.pdf
!ZapfDingbats.pdf
!bug878026.pdf
!issue1045.pdf

BIN
test/pdfs/issue13343.pdf Normal file

Binary file not shown.

View File

@ -132,6 +132,12 @@
"link": false,
"type": "eq"
},
{ "id": "issue13343",
"file": "pdfs/issue13343.pdf",
"md5": "f8bf1888839e15254555092c504e1900",
"rounds": 1,
"type": "eq"
},
{ "id": "bug921760",
"file": "pdfs/bug921760.pdf",
"md5": "1aa136d786a65b0d7cce7bdb3c58c6c3",