note 8814 deleted from function.strip-tags by vrana

From: Date: Mon, 22 Dec 2003 15:29:14 +0000
Subject: note 8814 deleted from function.strip-tags by vrana
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-62318@lists.php.net to get a copy of this message
Note Submitter: isbeam@usa.net ---- A function to filter out anything except "nice" HTML; ie TITLE tags (nasty) are escaped, while B tags are left alone. Doesn't try to validate though (make sure tages are closed/nested) function escapeBadHTML($str) { $allowed = "br|b|i|p|u|a"; $str = preg_replace("/< # match the open bracket ( # begin gathering (?! # followed by anything except... \/? # maybe a slash... ($allowed) # and one of the allowed chunks... \b # and a word boundary. ) # [^>]* # and any of not-">"'s ) # end gathering > # followed by the > /xis", "&lt;\\1&gt;", $str); return $str; }

« previous php.notes (#62318) next »