From 32ac9f14c800a8db2495387d371ed890fafdcac8 Mon Sep 17 00:00:00 2001 From: Nate Date: Fri, 20 Mar 2026 14:21:08 -0700 Subject: [PATCH] fix: iteratively strip HTML tags in search index builder Addresses CodeQL alert about incomplete multi-character sanitization. Co-Authored-By: Claude Opus 4.6 (1M context) --- docs-site/scripts/build-search-index.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs-site/scripts/build-search-index.ts b/docs-site/scripts/build-search-index.ts index 7f7b5383e..028662dcf 100644 --- a/docs-site/scripts/build-search-index.ts +++ b/docs-site/scripts/build-search-index.ts @@ -33,8 +33,14 @@ function getAllDocSlugs(nav: any[]): string[] { } function stripMdx(content: string): string { - return content - .replace(/<[^>]+>/g, "") + // Iteratively strip HTML tags to handle nested/malformed tags + let stripped = content; + let prev = ""; + while (prev !== stripped) { + prev = stripped; + stripped = stripped.replace(/<[^>]+>/g, ""); + } + return stripped .replace(/```[\s\S]*?```/g, "") .replace(/`[^`]+`/g, "") .replace(/!\[.*?\]\(.*?\)/g, "")