Skip to content

Commit 32ac9f1

Browse files
sestinjclaude
andcommitted
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) <noreply@anthropic.com>
1 parent 5635f6e commit 32ac9f1

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

docs-site/scripts/build-search-index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,14 @@ function getAllDocSlugs(nav: any[]): string[] {
3333
}
3434

3535
function stripMdx(content: string): string {
36-
return content
37-
.replace(/<[^>]+>/g, "")
36+
// Iteratively strip HTML tags to handle nested/malformed tags
37+
let stripped = content;
38+
let prev = "";
39+
while (prev !== stripped) {
40+
prev = stripped;
41+
stripped = stripped.replace(/<[^>]+>/g, "");
42+
}
43+
return stripped
3844
.replace(/```[\s\S]*?```/g, "")
3945
.replace(/`[^`]+`/g, "")
4046
.replace(/!\[.*?\]\(.*?\)/g, "")

0 commit comments

Comments
 (0)