Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Removing HTML tags from a sting

by Elgon (Curate)
on Nov 18, 2001 at 02:32 UTC ( #126048=note: print w/ replies, xml ) Need Help??

in reply to Removing HTML tags from a sting


This kind of thing is very important when using Perl for CGI and certain other applications (use SuperSearch to check up on the -T switch or taintchecking.)

Basically the way to do it is using regexps or one of the various modules listed above. The key is the philosophy with which you approach the problem - the way I think it should be done is that ANYTHING which is not expressly allowed should be forbidden: If, for example, you want to use some entered text for a message book then you should strip ALL characters except A-Z, a-z, 0-9 ,!. and maybe? This heads off just about any kind of problem because no tags such as the potential nasty <javascript> javascript code</javascript> can get through. If in doubt, write some code and post it here and ask for comment, I'm sure that the gods will not be upset.

Hope this helps.

"A nerd is someone who knows the difference between a compiled and an interpreted language, whereas a geek is a person who can explain it cogently to a non-geek over a couple of beers" - Elgon

Comment on Re: Removing HTML tags from a sting
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://126048]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-10-07 20:09 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (200 votes), past polls