diff --git a/lib/review-depth.ts b/lib/review-depth.ts index 5044c3b0a..7acf15c43 100644 --- a/lib/review-depth.ts +++ b/lib/review-depth.ts @@ -92,7 +92,8 @@ const SVG_HREF = /^\s*(?:#|data:image\/(?:png|jpe?g|gif|webp);base64,[A-Za-z0-9+ /** * Whether an SVG's whole text is a drawing (GST-911): every element in SVG_ELEMENTS, no event handler, every href or src a * same-document reference or an inline raster image, and nothing SVG_REFUSED names, read after character references are - * decoded. Anything else, an SVG that can run code included, stays code. + * decoded. Every name= in the text is read, so a stray quote cannot hide a later attribute inside its value; an unquoted value + * stops at the next =, which keeps the scan linear. Anything else, an SVG that can run code included, stays code. */ export function svgDrawing(text: string): boolean { const t = decodeCharRefs(text); @@ -102,7 +103,7 @@ export function svgDrawing(text: string): boolean { const tag = /^<\/?(?:[A-Za-z_][\w.-]*:)?([A-Za-z_][\w.-]*)/.exec(t.slice(at, at + 256)); if (!tag || !SVG_ELEMENTS.has(tag[1]!.toLowerCase())) return false; } - for (const m of t.matchAll(/(?]+))/g)) { + for (const m of t.matchAll(/(?=]+)))/g)) { const local = m[1]!.slice(m[1]!.lastIndexOf(':') + 1).toLowerCase(); if (local.startsWith('on') || ((local === 'href' || local === 'src') && !SVG_HREF.test(m[2] ?? m[3] ?? m[4] ?? ''))) return false; } diff --git a/test/review-packets-removed.test.ts b/test/review-packets-removed.test.ts index d84691081..9019a9b01 100644 --- a/test/review-packets-removed.test.ts +++ b/test/review-packets-removed.test.ts @@ -79,7 +79,7 @@ const REVIEWER_BRIEFS: Record = { 'review/specialists/testing.md': { sha: 'd6cc2bef7be562387d0c0a22fefe646dff9c295f1d34d8453a6cb496584150e4', replay: '#3638' }, 'review/specialists/targeted.md': { sha: '7f92a0d0a8319c3c0e076fb3b1a4689c45120b2be2c14dfc7d4cb03aafa9d6a5', replay: 'GST-257' }, 'scripts/resolvers/fix-check.ts': { sha: '712bf5b0c439e96bac32f19cbe25394dabb4c94aa66600100bfde9b100e15a08', replay: '#3638' }, - 'lib/review-depth.ts': { sha: 'd3b269015a8d97b4cf5654c0dacc5bea7562b96e3c1c3c6fc9442ef4bb336637', replay: 'GST-911' }, + 'lib/review-depth.ts': { sha: 'ff4c888f75ff9b8b898a96060eb758d1aad836f2cecdbe13d2408ab406a6f432', replay: 'GST-911' }, 'lib/review-risk.ts': { sha: 'df618e8aef3d641e8bf2073d8dca170740434acbb69c04555c4166df047f566c', replay: 'GST-911' }, };