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>
This commit is contained in:
parent
5635f6e5c5
commit
32ac9f14c8
1 changed files with 8 additions and 2 deletions
|
|
@ -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, "")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue