note 80861 added to function.strip-tags
| From: | sbritton at osu1 dot php dot net | Date: | Mon, 04 Feb 2008 18:35:24 +0000 |
| Subject: | note 80861 added to function.strip-tags | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135763@lists.php.net to get a copy of this message | ||
The function below corrects a typo in y5's function to strip tags and attributes - it also adds
lithium1330's recommended 's' parameter:
<?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) .
")=[\"\'][^\"\']*[\"\']/i', '/\s+/'),
array('', '', ' '), stripslashes('\\1')) .
'>'", strip_tags($sSource, implode('', $aAllowedTags)));
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 71.203.232.164
----
Manual Page -- http://www.php.net/manual/en/function.strip-tags.php
Edit -- https://master.php.net/note/edit/80861
Del: integrated -- https://master.php.net/note/delete/80861/integrated
Del: useless -- https://master.php.net/note/delete/80861/useless
Del: bad code -- https://master.php.net/note/delete/80861/bad+code
Del: spam -- https://master.php.net/note/delete/80861/spam
Del: non-english -- https://master.php.net/note/delete/80861/non-english
Del: in docs -- https://master.php.net/note/delete/80861/in+docs
Del: other reasons-- https://master.php.net/note/delete/80861
Reject -- https://master.php.net/note/reject/80861
Search -- https://master.php.net/manage/user-notes.php