in reply to (Ovid) Re: Default CGI.pm param() if none provided?
in thread Default CGI.pm param() if none provided?
In CGI parameters, there's not a big speed benefit, but for longer strings it can bail out if it matches one non-word character instead of having to match the whole thing.my $page = $q->param('page'); if (!(defined($page)) || ($page =~ /\W/)) { $page = 'home'; $q->param('page', $page); }
Another approach is to use transliteration:
if ($page =~ tr/A-Za-z0-9//dc) { $page = 'home'; }
Update: I missed most of the boat here, 'cuz I skipped over the bit where ybiC said "untaint". Different story altogether. Sorry buddy!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (3) Default CGI.pm param() if none provided? (clarification, success, thanks 8^)
by ybiC (Prior) on Dec 28, 2000 at 07:56 UTC |