Skip to content

Commit 5f17d50

Browse files
committed
fix(webview-ui): resolve CodeQL warning in stripCData by handling HTML-encoded CDATA markers and removing no-op replacement
1 parent 1b86bab commit 5f17d50

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

webview-ui/src/utils/diffUtils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ function isSearchReplace(s: string): boolean {
5555
function stripCData(s: string): string {
5656
return (
5757
s
58-
// HTML-encoded CDATA open
58+
// HTML-encoded CDATA open -> raw, then strip raw
5959
.replace(/<!\[CDATA\[/g, "<![CDATA[")
60-
// CDATA open
6160
.replace(/<!\[CDATA\[/g, "")
62-
// CDATA close (both encoded and raw)
61+
// HTML-encoded CDATA close -> raw, then strip raw
62+
.replace(/\]\]>/g, "]]>")
6363
.replace(/\]\]>/g, "")
6464
)
6565
}

0 commit comments

Comments
 (0)