diff --git a/src/infra/outbound/sanitize-text.test.ts b/src/infra/outbound/sanitize-text.test.ts index 2ab54a31d546..d4e93a64b4ed 100644 --- a/src/infra/outbound/sanitize-text.test.ts +++ b/src/infra/outbound/sanitize-text.test.ts @@ -137,6 +137,8 @@ describe("sanitizeForPlainText", () => { it("strips unknown/remaining tags", () => { expect(sanitizeForPlainText('text')).toBe("text"); expect(sanitizeForPlainText('link')).toBe("link"); + expect(sanitizeForPlainText("")).toBe("alert(1)"); + expect(sanitizeForPlainText("visible")).toBe("visible"); }); it("strips colon- and dot-qualified tags", () => { @@ -309,6 +311,67 @@ describe("sanitizeForPlainText", () => { expect(sanitizeForPlainText("a < b && c > d")).toBe("a < b && c > d"); }); + it.each([ + "Guard the retry loop: only retry while attempts0, otherwise give up.", + "Set the threshold so that latency4.", + "Use timeout<300 and n>0 for the probe.", + "a2", + "1<2>0", + "retry if attempts<3 and wait>5s", + "attempts5s", + "重试次数5秒", + "🙂5s", + "Set latencyd; }\n```\n\nand confirm concurrency>4 is safe.", + ])("preserves unspaced comparison prose in %s", (input) => { + expect(sanitizeForPlainText(input)).toBe(input); + }); + + it.each([10_000, 40_000])("bounds malformed comparison scanning with %i spaces", (size) => { + const input = `x5`; + const started = process.hrtime.bigint(); + const sanitized = sanitizeForPlainText(input); + const elapsedMs = Number(process.hrtime.bigint() - started) / 1e6; + + expect(sanitized).toBe("x5"); + expect(elapsedMs).toBeLessThan(500); + }); + + it.each([ + ["checkbox-after-value", 'x^2 • done', "x^2 • done"], + ["boolean-after-value", 'todo', "todo"], + ["boolean-only", "todo", "todo"], + ["boolean-first", 'done', "done"], + ["interleaved", 'done', "done"], + ["autofocus-after-value", 'ready', "ready"], + ["controls-after-value", '