Skip to content

Commit cb8bfa4

Browse files
committed
test(media-use): size payloads that fail the old scans fast instead of hanging
1 parent 502d8d6 commit cb8bfa4

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎packages/core/src/figma/sanitizeSvg.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,16 @@ describe("sanitizeSvg: structural edge cases", () => {
266266
});
267267
});
268268

269-
// Both payloads took minutes under the earlier regex scans (cubic and quadratic backtracking).
269+
// Each took 8s+ under the earlier regex scans (cubic and quadratic backtracking); now ~3ms.
270270
describe("sanitizeSvg: hostile input size", () => {
271271
const HUGE_CASES: Array<[label: string, input: string]> = [
272272
[
273-
"unclosed url( + 20k spaces in style=",
274-
`<svg><rect style="fill:url(${" ".repeat(20_000)}x"/></svg>`,
273+
"unclosed url( + 4k spaces in style=",
274+
`<svg><rect style="fill:url(${" ".repeat(4_000)}x"/></svg>`,
275275
],
276276
[
277-
"200k-char word with no paren in <style>",
278-
`<svg><style>.a{fill:${"a".repeat(200_000)}}</style></svg>`,
277+
"100k-char word with no paren in <style>",
278+
`<svg><style>.a{fill:${"a".repeat(100_000)}}</style></svg>`,
279279
],
280280
];
281281
for (const [label, input] of HUGE_CASES) {

0 commit comments

Comments
 (0)