Skip to content

Commit b1ba30c

Browse files
bad html filtering regexp
1 parent 7b16bd1 commit b1ba30c

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

CWE-80/main.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
const main = (html) => {
2-
const scriptRegex = /<script\b[^>]*>([\s\S]*?)<\/script>/gi
3-
let match
2+
const regex = /<script\b[^>]*>([\s\S]*?)<\/script>/gi
43

5-
while ((match = scriptRegex.exec(html)) !== null) {
6-
html = html.replace(match[0], match[1])
4+
if (regex.test(html)) {
5+
document.body.innerHTML = html
76
}
8-
9-
return html
107
}

0 commit comments

Comments
 (0)