The HTML5 clipboard is awesome, but I am looking for a way to make it safe.
The user is pasting text/html into my webpage. This allows them to paste images, tables, etc.
I am looking for a way to remove all scripts from the pasted content, before I add it to the page.
I need to remove <script>
elements, as well as other ways of executing scripts like
<img src="x" onerror="alert('Hacked!')">
(and any others)
I do not want to remove style elements, or any other sorts of elements. (They are actually pasting into an iframe, so styles won't affect anything else.)