Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You need to escape =. Otherwise if someone does something like:

document.write("<a class=" + str + " href='foo'>xss</a>");

The attacker can set str to "foo onclick=alert(1)".



You can't safely put arbitrary user input in an unquoted attribute value.


You should put quotes around the attribute value.

Then you won't need to escape =.


The issue is when a developer forgets to do so. No reason to not escape it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: