coolmichael has asked for the wisdom of the Perl Monks concerning the following question:
sub badinputerror ($) { my $q = shift; print $q->header('text/plain'); print <<"EOHTML"; There was an error with your input. Please try again. EOHTML die "input did not pass taint checking\n"; } sub untaint ($$$) { my $q = shift; my $name = shift; my $re = shift; my $tainted = $q->param($name); my $untainted = undef; $untainted = $1 if($tainted =~ m/^($re)$/); badinputerror($q) unless($untainted); return $untainted; } # # And later on in the code, for example # my $username=untaint($q, 'user', "[a-zA-Z][a-zA-Z0-9_]+");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI question: untainting a lot of variables
by crazyinsomniac (Prior) on Dec 31, 2001 at 11:28 UTC | |
|
Re: CGI question: untainting a lot of variables
by belg4mit (Prior) on Dec 31, 2001 at 06:57 UTC | |
by jlongino (Parson) on Dec 31, 2001 at 09:14 UTC | |
by BMaximus (Chaplain) on Dec 31, 2001 at 10:52 UTC | |
|
Re: CGI question: untainting a lot of variables
by mkmcconn (Chaplain) on Dec 31, 2001 at 11:34 UTC |