From 9c37518f75d9a4e0479319aa85efdeea533852fb Mon Sep 17 00:00:00 2001 From: Atlas Date: Thu, 2 Apr 2026 21:30:51 -0700 Subject: [PATCH] Potential fix for code scanning alert no. 14: Incomplete multi-character sanitization Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- docs-engine/src/scraping/sphinxScraper.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs-engine/src/scraping/sphinxScraper.ts b/docs-engine/src/scraping/sphinxScraper.ts index e4bc792..42c6eeb 100644 --- a/docs-engine/src/scraping/sphinxScraper.ts +++ b/docs-engine/src/scraping/sphinxScraper.ts @@ -1008,6 +1008,15 @@ export class SphinxScraper { md = md.replace(/[ \t]+\n/g, '\n'); md = md.replace(/\n{3,}/g, '\n\n'); + // As a final safety step, strip any script tags that might have been + // reintroduced by HTML entity decoding above. + let prev: string; + const scriptTagPattern = /]*>[\s\S]*?<\/script>/gi; + do { + prev = md; + md = md.replace(scriptTagPattern, ''); + } while (md !== prev); + return md.trim(); } }