I'm learning xss prevention through this ppt:http://stash.github.io/empirejs-2014/#/2/23, and I have a question on this page.
It says "JavaScript sanitization doesn't save you from innerHTML", and I tried a simple test like this:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>test</title> </head> <body> <div id="test"></div> <script> var userName = "Jeremy\x3Cscript\x3Ealert('boom')\x3C/script\x3E"; document.getElementById('test').innerHTML = "<span>"+userName+"</span>"; </script> </body> </html> when I opened this html on my browser(chrome), I only saw the name "Jeremy",by using F12, I saw
<div id="test"><span>Jeremy<script>alert('boom')</script></span></div> Although the script had been added to html, the alert box didn't come out.
"JavaScript sanitization doesn't save you from innerHTML" I think this means that the word "boom" should be alerted. Am I right?