P
phill hw
Hello Usenet Perl,
I have a html form which produces a load of checkboxes. They all have the
same name (sports) and if a check box is ticked(checked) it holds a numeric value
which represents the id of the sport.:
Pseudo CGI FORM:
<FORM>
<input type="text" name="s" value="aslakslad1231">
<p><input type="checkbox" name="sport" value="1">Football</p>
<p><input type="checkbox" name="sport" value="2">Basketball</p>
<p><input type="checkbox" name="sport" value="3">Hockey</p>
<SUBMIT BUTTON>
</FORM>
When the form data is send to the cgi script for processing:
This works with taint on, but I have to parse the values in the @sports
array and put them into another array (@tsports) before I can use them. If I do
not use this second array the data in the @sports array is still considered
tainted and I cannot use it:
#!/usr/bin/perl -Tw
use strict;
use CGI qw/:standard :html3/;
use CGI::Carp 'fatalsToBrowser';
if (param())
{
my ($query) = new CGI;
my ($s) = $query->param('s') =~ /^([\w]+)$/ if $query->param('s');
my (@sports) = $query->param('sports');
my (@tsports);
foreach(@sports)
{
if ($_ =~ /^([\d]+)$/)
{
push(@tsports, $_);
}
}
}
If I use the following script, I cannot use the data contained in the @sports array
as it is still considered tainted.
#!/usr/bin/perl -Tw
use strict;
use CGI qw/:standard :html3/;
use CGI::Carp 'fatalsToBrowser';
if (param())
{
my ($query) = new CGI;
my ($s) = $query->param('s') =~ /^([\w]+)$/ if $query->param('s');
my (@sports) = $query->param('sports')=~ /^([\d]+)$/ if $query->param('sports');
}
How can I correctly parse the @sports array to allow for numbers only without
having to construct a second array? Is this possible or doe I hav to
parse the contents of the first array and effectively do a taint check on each value
contained in the first array?
Thankyou
Phill
I have a html form which produces a load of checkboxes. They all have the
same name (sports) and if a check box is ticked(checked) it holds a numeric value
which represents the id of the sport.:
Pseudo CGI FORM:
<FORM>
<input type="text" name="s" value="aslakslad1231">
<p><input type="checkbox" name="sport" value="1">Football</p>
<p><input type="checkbox" name="sport" value="2">Basketball</p>
<p><input type="checkbox" name="sport" value="3">Hockey</p>
<SUBMIT BUTTON>
</FORM>
When the form data is send to the cgi script for processing:
This works with taint on, but I have to parse the values in the @sports
array and put them into another array (@tsports) before I can use them. If I do
not use this second array the data in the @sports array is still considered
tainted and I cannot use it:
#!/usr/bin/perl -Tw
use strict;
use CGI qw/:standard :html3/;
use CGI::Carp 'fatalsToBrowser';
if (param())
{
my ($query) = new CGI;
my ($s) = $query->param('s') =~ /^([\w]+)$/ if $query->param('s');
my (@sports) = $query->param('sports');
my (@tsports);
foreach(@sports)
{
if ($_ =~ /^([\d]+)$/)
{
push(@tsports, $_);
}
}
}
If I use the following script, I cannot use the data contained in the @sports array
as it is still considered tainted.
#!/usr/bin/perl -Tw
use strict;
use CGI qw/:standard :html3/;
use CGI::Carp 'fatalsToBrowser';
if (param())
{
my ($query) = new CGI;
my ($s) = $query->param('s') =~ /^([\w]+)$/ if $query->param('s');
my (@sports) = $query->param('sports')=~ /^([\d]+)$/ if $query->param('sports');
}
How can I correctly parse the @sports array to allow for numbers only without
having to construct a second array? Is this possible or doe I hav to
parse the contents of the first array and effectively do a taint check on each value
contained in the first array?
Thankyou
Phill