1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Ensure that the Widths array is parsed correctly in PartialEvaluator.preEvaluateFont

*Please note:* While I don't have a document that this patches fixes, the current code is however not entirely correct as far as I can tell.

Looking at how the `Widths` array is parsed in `PartialEvaluator.extractWidths`, it's clear that the implementation in `PartialEvaluator.preEvaluateFont` is a bit too simplistic. In particular, by only wrapping the data into a TypedArray, there's no attempt to handle *indirect* objects which could potentially lead to colliding `hash`es being computed.
This commit is contained in:
Jonas Jenwald 2021-05-07 12:44:20 +02:00
parent 30b2739adf
commit 8a1cb82aee

View file

@ -3616,9 +3616,14 @@ class PartialEvaluator {
}
const widths = dict.get("Widths") || baseDict.get("Widths");
if (widths) {
uint8array = new Uint8Array(new Uint32Array(widths).buffer);
hash.update(uint8array);
if (Array.isArray(widths)) {
const widthsBuf = [];
for (const entry of widths) {
if (isNum(entry) || isRef(entry)) {
widthsBuf.push(entry.toString());
}
}
hash.update(widthsBuf.join());
}
if (composite) {