Merge pull request #20160 from calixteman/issue20155
Check the setDash arguments
This commit is contained in:
commit
7ea7a94ed5
@ -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:
|
||||
|
||||
@ -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 () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user