Is there an easy way to remove with php any type of event HTML in php string. For example for events submit,mouseOut,mouseOver,click,blur,focus,etc. to prevent javascript injection, for cases like these:
is There an easy way to remove with php any type of event HTML in php srtring. For example for events submit,mouseOut,mouseOver,click,blur,focus,etc. to prevent javascript injection, for cases like these:
$text= 'mi secure html <div id="javascript_injection" onfocus=function(){SomeJavaScriptCode}></div> <p> Im interested in showing the resulting html </p>'
echo $text = 'mi secure html <div id="javascript_injection" > example </div> <b> Im interested in showing the resulting html </b>
I'm also interested in showing this:
'mi secure html <div id="javascript_injection" > example </div> <b> Im interested in showing the resulting html </b>
PD:I can not escape all the text or remove all tags because there are parts that if I want to show in html.Imagine you want to show a user creates html to another and want to avoid the injection of javascript
imgelements, you should checksrc(and other non-obvious constructs) as well, as it may contain JavaScript. There are many other edge cases as well. See XSS cheat sheet. As Wayne Whitty already said, where is this text coming from?