note 83042 added to function.strip-tags
| From: | MassoudAbbagash at osu1 dot php dot net | Date: | Wed, 07 May 2008 22:56:04 +0000 |
| Subject: | note 83042 added to function.strip-tags | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-139157@lists.php.net to get a copy of this message | ||
Danno, your script has a flaw.
Try this :
<?php
function strip_tags_keep_links($sSource)
{
return preg_replace('/<(.*?)>/ie', "'<' .
preg_replace(array('/javascript:[^\"\']*/i',
'/\b((?![hH][rR][eE][fF]\b)\w+)[ \\t\\n]*=[
\\t\\n]*[\"\'][^\"\']*[\"\']/i', '/\s+/'),
array('', '', ' '), stripslashes('\\1')) .
'>'", strip_tags($sSource,'<a>'));
}
$source = "<a href=javascript:alert('doesn\'t work!')
title=\"move your mouse here\" href=http://www.a_web_site.org
onmouseover\n=\nalert(\"doesn\'t work!\")
onmouseover='alert(\"doesn\'t work!\")' alt=\"move your mouse
here\" > test</a>";
$result=strip_tags_keep_links($source);
echo($result);
?>
----
Server IP: 217.174.223.124
Probable Submitter: 83.186.40.100
----
Manual Page -- http://www.php.net/manual/en/function.strip-tags.php
Edit -- https://master.php.net/note/edit/83042
Del: integrated -- https://master.php.net/note/delete/83042/integrated
Del: useless -- https://master.php.net/note/delete/83042/useless
Del: bad code -- https://master.php.net/note/delete/83042/bad+code
Del: spam -- https://master.php.net/note/delete/83042/spam
Del: non-english -- https://master.php.net/note/delete/83042/non-english
Del: in docs -- https://master.php.net/note/delete/83042/in+docs
Del: other reasons-- https://master.php.net/note/delete/83042
Reject -- https://master.php.net/note/reject/83042
Search -- https://master.php.net/manage/user-notes.php