note 41586 added to function.preg-replace
| From: | paul at liversidge dot info | Date: | Thu, 15 Apr 2004 15:44:05 +0000 |
| Subject: | note 41586 added to function.preg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-68167@lists.php.net to get a copy of this message | ||
A function to remove XSS exploits from text strings by replacing the dangerous HTML tags with safe
equivalents.
function xss_remove ($text) {
//Replaces <script>, <img> and <iframe> tags with safe HTML equivalents
$text = preg_replace ("~(</*script.*?>|<img.*?>|</*iframe>)~ise",
"htmlentities (stripslashes (\\"$1\\"))", html_entity_decode (urldecode
($text)));
return $text;
} # xss_remove
----
Manual Page -- http://www.php.net/manual/en/function.preg-replace.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41586
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41586&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41586&report=yes
Search -- http://master.php.net/manage/user-notes.php