From f5cf05789af57d78261f48f17aa5de8866f434ea Mon Sep 17 00:00:00 2001 From: kanywst Date: Sun, 25 Oct 2026 00:46:56 +0900 Subject: [PATCH 1/2] fix(readme): strip link-text markup to a fixed point CodeQL (js/incomplete-multi-character-sanitization) flagged the single-pass tag strip: 'ipt>' left ' { expect(p).toEqual({ kind: "text", segs: [{ text: "it's 'fine' ' <b>" }] }); }); + it("leaves no markup behind in link text, even when tags are nested to dodge one pass", () => { + const [p] = parseBlocks(`

ipt>alert(1)y

`); + if (p.kind !== "text") throw new Error("expected text"); + expect(p.segs).toHaveLength(1); + expect(p.segs[0].text).not.toMatch(/[<>]/); + expect(p.segs[0].text).toContain("alert(1)y"); + }); + it("survives references that name no real character", () => { const [p] = parseBlocks("

a�b�c�d&bogus;e

"); expect(p).toEqual({ kind: "text", segs: [{ text: "a\ufffdb\ufffdc\ufffdd&bogus;e" }] }); diff --git a/src/lib/readme.ts b/src/lib/readme.ts index bade5eb..1e71399 100644 --- a/src/lib/readme.ts +++ b/src/lib/readme.ts @@ -54,12 +54,23 @@ function decode(s: string): string { }); } +// Removes markup until none is left: one pass over "ipt>" would leave "