I would like to use PHP-based tool HTML Purifier on a textbox to prevent xss but I would like to allow the following:
- basic tags like
<b>,<i>,<u> - links
- images
I would like to block all CSS and JavaScript. I just tried HTML Purifier and it failed on this case. Just see this example. How can I take care of this?
Also I would want all words of the form #abcd and @abcd to be replaced with custom html (as you would have guessed it a link). Is it possible with this or do I have to do my own replace?
Regular expressions and e modifier
function checkTag( $tag ) { $tag = removeslashes( $tag ); ... return $secureTag; } $html = preg_replace( "/<[^>]+>/e", " checkTag( '\$0' )", $input );