<p onclick="javascript:alert(333);" onerror="javascript:alert(331)" onload="javascript:window.location.href=''">
test</p><a onload="javascript:alert(11);">test</a>怎么过滤掉标签内的这些js事件?
如果是完全匹配事件的话,事件太多了,列举起来比较麻烦。
我的想法是能不能过滤掉以 on 开头的属性,并且能过滤掉全部的事件。
test</p><a onload="javascript:alert(11);">test</a>怎么过滤掉标签内的这些js事件?
如果是完全匹配事件的话,事件太多了,列举起来比较麻烦。
我的想法是能不能过滤掉以 on 开头的属性,并且能过滤掉全部的事件。
$html=<<<EOF
<body contenteditable="true" onload="javascript:alert('111');" onclick="javascript:alert(fsdfsd)">
EOF;$regList = "/(<.*?)\s+(on\w+)\s*?=\s*?[\"|\'].*?[\"|\']([^>]*?>)/is";while(preg_match($regList,$html))
{
//什么原因,不能一次性过滤完?
$html = preg_replace($regList,'$1$3',$html);
}
不加while条件的话,一个标签只能过滤一个事件,这个是怎么回事?