D
Daniel M. Hendricks
I'm looking for a function/regex in C# to strip unwanted HTML tags from
comments posted to my web site. Previously, it was written in PHP and
I used this function to strip unwanted tags:
function removeEvilTags($source)
{
$allowedTags='<b><i><blockquote><ul><ol><li><br><a>';
$source = strip_tags($source, $allowedTags);
return preg_replace('/<(.*?)>/ie',
"'<'.removeEvilAttributes('\\1').'>'", $source);
}
I'd like to do the same in C# - strip all tags from the submission
except the following: <b>, <i>, <blockquote>, <ul>, <ol>, <li>, <br>,
<a>.
Can someone give an example of how to do this?
Thanks,
Daniel
http://www.danhendricks.com
comments posted to my web site. Previously, it was written in PHP and
I used this function to strip unwanted tags:
function removeEvilTags($source)
{
$allowedTags='<b><i><blockquote><ul><ol><li><br><a>';
$source = strip_tags($source, $allowedTags);
return preg_replace('/<(.*?)>/ie',
"'<'.removeEvilAttributes('\\1').'>'", $source);
}
I'd like to do the same in C# - strip all tags from the submission
except the following: <b>, <i>, <blockquote>, <ul>, <ol>, <li>, <br>,
<a>.
Can someone give an example of how to do this?
Thanks,
Daniel
http://www.danhendricks.com