What you could do is put the B1 .. B6 parameters in a separate array and do the or 0 trick on them. Put the other parameters in the first array and do something like this:my @expected = qw( title requester department etc ); my @request; foreach my $expect (@expected) { push @request, ($q->param($expect) or '0'); }
This way, you don't have a malicious HTML hijacker pass bad data and have it end up in your file somewhere. Plus, you get to check immediately.foreach my $expect (@expected) { my $received = $q->param($expect); unless (defined $received) { $error .= "Didn't get $expect parameter!\n"; last; # and do an error somewhere } push @request, $received; }
Update: isotope makes a good point below. A little client-side JavaScript is good for verifying submissions, but some users have it disabled (for good reason), and my point about not trusting the client still applies. Just be friendly about it, as isotope recommends.
In reply to Re: Easy way to run tests on many CGI params?
by chromatic
in thread Easy way to run tests on many CGI params?
by meonkeys
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |