Beefy Boxes and Bandwidth Generously Provided by pair Networks Russ
No such thing as a small change
 
PerlMonks  

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)


Comment on Re: removing special characters
Download Code
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
    newrisedesigns.com

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (10)
As of 2014-04-18 09:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (465 votes), past polls