Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: removing special characters

by extremely (Priest)
on Feb 13, 2003 at 17:50 UTC ( [id://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
    newrisedesigns.com

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-03-28 23:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found