Input
Comment body: `Hello, world!`
Output
Comment renders with the text "Hello, world!" visible.
Normal input must still work after your fix.
This comment form works fine for normal users — but it has two security vulnerabilities that would let an attacker run arbitrary JavaScript in anyone's browser. Your job is to find both bugs in `main.js` and fix them. N...
index.htmlEditable startermain.jsEditable starterComment body: `Hello, world!`
Comment renders with the text "Hello, world!" visible.
Normal input must still work after your fix.
Comment body: `<img src="x" onerror="window.__XSS__=true">`
The literal text is shown. No JS runs.
The onerror handler must never fire — use textContent, not innerHTML.
This fix handles XSS at the rendering layer. Real apps often use a Content Security Policy (CSP) header as a second line of defense — even if a payload somehow gets into the DOM, a strict CSP prevents it from executing. How would you write a CSP that blocks inline scripts but still allows your app to function?