Cleaning all inline events from HTML tags

Posted by Itay Moav on Stack Overflow See other posts from Stack Overflow or by Itay Moav
Published on 2009-08-11T03:59:42Z Indexed on 2010/04/08 12:03 UTC
Read the original article Hit count: 362

Filed under:
|
|
|

For HTML input, I want to neutralize all HTML elements that have inline js (onclick="..", onmouseout=".." etc). I am thinking, isn't it enough to encode the following chars? =,(,)

So onclick="location.href='ggg.com'"
will become onclick%3D"location.href%3D'ggg.com'"

What am I missing here?

Edit: I do need to accept active HTML (I can't escape it all or entities is it).

© Stack Overflow or respective owner

Related posts about html

Related posts about sanitization