Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: removing special characters

by extremely (Priest)
on Feb 13, 2003 at 17:50 UTC ( #235040=note: print w/replies, xml ) Need Help??

in reply to removing special characters

Don't think of it as removing the special characters. Think of it as keeping the safe/useful characters. It is a subtle thing but you'll be well served in the future if you keep that attitude. You can spend all day adding more and more special characters or you can just removed everything that you aren't sure is valid. You'll always miss things but it is easier to allow one extra thing you missed than clean up your database or hacked server when you allowed something you shouldn't have.

As an example, to keep only upper case letters and numbers, you might do: $scalar =~ s/[^A-Z0-9]+//g; which removes from the string every character that isn't in the A-Z or 0-9 range.

$you = new YOU;
honk() if $you->love(perl)

Replies are listed 'Best First'.
Re: Re: (nrd) removing special characters
by newrisedesigns (Curate) on Feb 13, 2003 at 20:37 UTC

    Taint check. It is the only way.™

    my $param = $q->param("text") || ''; #for example... if($param =~ /^([\w\s]+)/){ # modify as needed $param = $1; } else{ return 0; # or die, or croak, or warn, or something! }

    John J Reiser

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2020-10-25 16:53 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (249 votes). Check out past polls.