Skip to content

Commit 7b16bd1

Browse files
docs
1 parent 20e5eec commit 7b16bd1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

CWE-80/main.js

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

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

0 commit comments

Comments
 (0)