note 41586 deleted from function.preg-replace by nlopess
| From: | nlopess@php.net | Date: | Tue, 07 Sep 2004 09:15:29 +0000 |
| Subject: | note 41586 deleted from function.preg-replace by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76135@lists.php.net to get a copy of this message | ||
Note Submitter: paul at liversidge dot info
----
A function to remove XSS exploits from text strings by replacing the dangerous HTML tags with safe
equivalents.
<?php
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;
}
?>