Gossamer Forum
Home : General : Perl Programming :

HTML discrimination

Quote Reply
HTML discrimination
I've seen this topic somewhere in this forum, but I can't find it.

How do I rip off HTML tags from the data that user submitted, or at least detect HTML tags or parts of HTML tags.
Some users might try to submit something like:

Code:

</a><img scr=\"http://url.com/junk.jpg\">

or

Code:

\"><h1>Unwanted stuff</h1>

or even a whole HTML document. I need to prevent it for well known reasons.


Thank you in advance.


Pasha

------------------
webmaster@find.virtualave.net
http://find.virtualave.net
Quote Reply
Re: HTML discrimination In reply to
try this:



if ($line =~ /<a\s+href[^>]+>([^<]+)<\/a>/i){
&site_html_add_failure ("You're message!! ");
return;
}
Quote Reply
Re: HTML discrimination In reply to
I would check out the HTML::Parse module, available at CPAN.

-mark

Quote Reply
Re: HTML discrimination In reply to
chrishintz,

So far I have:

Code:

if ($fields{'url'}=~/\http:/) {
}
elsif ($fields{'url'} =~ /<a\s+href[^>]+>([^<]+)<\/a>/i)
{
$error_url =1;
}
else {
$error_url =1;
}

and it's not working. It still does not detect if a user submitted an HTML tag.


Regards,

Pasha

------------------
webmaster@find.virtualave.net
http://find.virtualave.net