Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Re: First Time Untainting Data

by svsingh (Priest)
on Oct 10, 2003 at 17:05 UTC ( #298322=note: print w/ replies, xml ) Need Help??

in reply to Re: First Time Untainting Data
in thread First Time Untainting Data

Thanks for the tip. I rewrote the untaint subroutine as follows (borrowing from perlsec):

sub untaint { my $s = $_[0]; if ($s =~ /^([\w \-\@\(\)\,\.\/]+)$/) { $s = $1; # $data now untainted } else { die "Bad data in $s"; # log this somewhere } return $s; }

When I get home, I'll look into writing a separate untaint subroutine for each field, but is this more correct than the original?

Thanks again.

Comment on Re: Re: First Time Untainting Data
Download Code
Replies are listed 'Best First'.
Re: First Time Untainting Data
by Abigail-II (Bishop) on Oct 10, 2003 at 17:10 UTC
    This is at least a syntactical valid way of untainting the data, but I do not know whether it's semantically correct. That depends on how the data is used. And do yourself (and all readers of your code), don't backwack everything. Only use a backslash when it's really needed. Like this:
    if ($s =~ m{^([-\w \@(),./]+)$}) {


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2015-11-30 13:50 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (771 votes), past polls