note 81460 added to function.strip-tags

From: Date: Fri, 29 Feb 2008 03:37:45 +0000
Subject: note 81460 added to function.strip-tags
Groups: php.notes 
Request: Send a blank email to php-notes+get-136581@lists.php.net to get a copy of this message
An update to sbritton's function: If you have whitespace between the = sign and the attribute, it would bypass the regex. This updates that. <?php function strip_tags_attributes($sSource, $aAllowedTags = array(), $aDisabledAttributes = array('onclick', 'ondblclick', 'onkeydown', 'onkeypress', 'onkeyup', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', '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))); } ?> ---- Server IP: 64.71.164.2 Probable Submitter: 74.142.51.142 ---- Manual Page -- http://www.php.net/manual/en/function.strip-tags.php Edit -- https://master.php.net/note/edit/81460 Del: integrated -- https://master.php.net/note/delete/81460/integrated Del: useless -- https://master.php.net/note/delete/81460/useless Del: bad code -- https://master.php.net/note/delete/81460/bad+code Del: spam -- https://master.php.net/note/delete/81460/spam Del: non-english -- https://master.php.net/note/delete/81460/non-english Del: in docs -- https://master.php.net/note/delete/81460/in+docs Del: other reasons-- https://master.php.net/note/delete/81460 Reject -- https://master.php.net/note/reject/81460 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136581) next »