Merge pull request #20160 from calixteman/issue20155

Check the setDash arguments
This commit is contained in:
Tim van der Meij 2025-08-12 20:48:44 +02:00 committed by GitHub
commit 7ea7a94ed5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 28 additions and 0 deletions

View File

@ -2206,6 +2206,22 @@ class PartialEvaluator {
args[0] = Math.abs(thickness);
break;
}
case OPS.setDash: {
const dashPhase = args[1];
if (typeof dashPhase !== "number") {
warn(`Invalid setDash: ${dashPhase}`);
continue;
}
const dashArray = args[0];
if (!Array.isArray(dashArray)) {
warn(`Invalid setDash: ${dashArray}`);
continue;
}
if (dashArray.some(x => typeof x !== "number")) {
args[0] = dashArray.filter(x => typeof x === "number");
}
break;
}
case OPS.moveTo:
case OPS.lineTo:
case OPS.curveTo:

View File

@ -357,6 +357,18 @@ describe("evaluator", function () {
expect(result.argsArray).toEqual([]);
expect(result.fnArray).toEqual([]);
});
it("should handle invalid dash stuff", async function () {
const stream = new StringStream("[ none ] 0 d");
const result = await runOperatorListCheck(
partialEvaluator,
stream,
new ResourcesMock()
);
expect(result.argsArray[0][0]).toEqual([]);
expect(result.argsArray[0][1]).toEqual(0);
expect(result.fnArray[0]).toEqual(OPS.setDash);
});
});
describe("thread control", function () {