note 81553 deleted from function.strip-tags by danbrown

From: Date: Sun, 17 May 2009 15:55:01 +0000
Subject: note 81553 deleted from function.strip-tags by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154714@lists.php.net to get a copy of this message
Note Submitter: brian at diamondsea dot com ---- An update agolna's update to sbritton's function: Adds additional javascript events to the aDisabledAttributes array. <?php function strip_tags_attributes($sSource, $aAllowedTags = array(), $aDisabledAttributes = array('onabort', 'onblue', 'onchange', 'onclick', 'ondblclick', 'onerror', 'onfocus', 'onkeydown', 'onkeyup', 'onload', 'onmousedown', 'onmousemove', 'onmouseover', 'onmouseup', 'onreset', 'onresize', 'onselect', 'onsubmit', 'onunload')) { if (empty($aDisabledAttributes)) return strip_tags($sSource, implode('', $aAllowedTags)); return preg_replace('/<(.*?)>/ie', "'<' . preg_replace(array('/javascript:[^\"\']*/i', '/(" . implode('|', $aDisabledAttributes) . ")[ \\t\\n]*=[ \\t\\n]*[\"\'][^\"\']*[\"\']/i', '/\s+/'), array('', '', ' '), stripslashes('\\1')) . '>'", strip_tags($sSource, implode('', $aAllowedTags))); } ?>

« previous php.notes (#154714) next »