1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| function stripJS($html)
{
function sjs_stiptags($c)
{
$em = '*?= *?(["|\']).*?\\1`is';
$jsev = array (
"`onclick $em",
"`onchange $em",
"`onabort $em",
"`onafterupdate $em",
"`onblur $em",
"`ondbclick $em",
"`onerror $em",
"`onfocus $em",
"`onhelp $em",
"`onkeydown $em",
"`onkeypress $em",
"`onkeyup $em",
"`onload $em",
"`onmousedown $em",
"`onmousemove $em",
"`onmouseout $em",
"`onmouseover $em",
"`onmouseup $em",
"`onreadystatechange $em",
"`onreset $em",
"`onresize $em",
"`onscroll $em",
"`onselect $em",
"`onsubmit $em",
"`onunload $em"
);
return preg_replace($jsev, '', $c[0]);
}
do {
$html = preg_replace('`<script.*</script.*>`Uis', '', $html);
} while (preg_match('`<script.*</script.*>`Uis', $html));
$html = preg_replace_callback('`<[a-zA-Z/!\?].*?>`s', 'sjs_stiptags', $html);
return $html;
} |
Partager