Skip to content

Commit 8f0d873

Browse files
fix: potential fix for code scanning alert no. 4: Incomplete multi-character sanitization
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent ff94c04 commit 8f0d873

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

playwright/utils/prettify.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { prettyPrint } from 'html'
22

33
export function formatHTML(rawHTMLString: string): string {
4-
const removeComments = rawHTMLString.replaceAll(/<!--.*?-->/gs, '')
4+
let removeComments = rawHTMLString
5+
let prev
6+
do {
7+
prev = removeComments
8+
removeComments = removeComments.replaceAll(/<!--.*?-->/gs, '')
9+
} while (removeComments !== prev)
510
// eslint-disable-next-line camelcase
611
const pretty = prettyPrint(removeComments, { indent_size: 2 })
712
const removeEmptyLines = `${pretty}\n`.replaceAll(/\n{2,}/g, '\n')

0 commit comments

Comments
 (0)