Is there an easy way to remove with php
php 字符串中的任何类型的事件 HTML。例如事件 提交、mouseOut、mouseOver、单击、模糊、聚焦等。为了防止 javascript 注入,对于以下情况:是否有一种简单的方法可以使用 php删除 php srtring 中的任何类型的事件 HTML。例如事件 提交、mouseOut、mouseOver、单击、模糊、聚焦等。为了防止 javascript 注入,对于以下情况:
$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>
我也有兴趣展示这个:
'mi secure html <div id="javascript_injection" > example </div> <b> Im interested in showing the resulting html </b>
PD:我无法转义所有文本或删除所有标签,因为如果我想在 html 中显示某些部分。Imagine you want to show a user creates html to another and want to avoid the injection of javascript