| 1 | package CGI::NoPoison; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use Carp 'croak'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | our $VERSION = '3.11'; | |||||||||
| 6 | |||||||||||
| 7 | #note that we are overriding AUTOLOADed methods in CGI.pm in this way | ||||||||||
| 8 | #so we aren't having to use the "no warnings 'redefine'" pragma ;) | ||||||||||
| 9 | 3 | ▶ | sub CGI::FETCH { | ||||||||
|
Subroutine
FETCH: called CC=4 SCAR=14.0
| |||||||||||
| 10 | 3 | ▶ | return $_[0] if $_[1] eq 'CGI'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 11 | 3 | ▶ | return undef unless defined $_[0]->param($_[1]); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | #Instead of returning a null-byte packed list, introducing | ||||||||||
| 13 | #potential security problems, why not instead return an | ||||||||||
| 14 | #anonymous array and just dereference it later ? | ||||||||||
| 15 | #return join("\0",$_[0]->param($_[1])); | ||||||||||
| 16 | 3 | my @a = $_[0]->param($_[1]); | |||||||||
| 17 | 3 | ▶ | if ( scalar( @a ) > 1 ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | { | ||||||||||
| 19 | 2 | return [$_[0]->param($_[1])]; # return anon-array if more than one element | |||||||||
| 20 | } | ||||||||||
| 21 | else | ||||||||||
| 22 | { | ||||||||||
| 23 | 1 | return $_[0]->param($_[1]); # behave normally otherwise, so we have a true drop-in replacement | |||||||||
| 24 | } | ||||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | #and if we're going to do THAT, well, we might as well | ||||||||||
| 28 | 0 | ▶ | sub CGI::SplitParam { | ||||||||
|
Subroutine
SplitParam: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 29 | 0 | my ($param) = @_; | |||||||||
| 30 | #my (@params) = split ("\0", $param); | ||||||||||
| 31 | #my (@params) = @{$param}; # wait, why bother with this? | ||||||||||
| 32 | #return (wantarray ? @params : $params[0]); | ||||||||||
| 33 | 0 | ▶ | return (wantarray ? @{$param} : @{$param}[0]);# when you can just do this, instead! :) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | #and also should probably | ||||||||||
| 37 | 0 | ▶ | sub CGI::STORE { | ||||||||
|
Subroutine
STORE: not called CC=2 SCAR=17.9
| |||||||||||
| 38 | 0 | my $self = shift; | |||||||||
| 39 | 0 | my $tag = shift; | |||||||||
| 40 | # this should now be a reference to a named or an anonymous array | ||||||||||
| 41 | # ala $vals = [ qw(list goes here) ]; or $vals = \@ary; | ||||||||||
| 42 | 0 | my $vals = shift; | |||||||||
| 43 | #my @vals = index($vals,"\0")!=-1 ? split("\0",$vals) : $vals; | ||||||||||
| 44 | 0 | ▶ | croak "Value list not an array reference" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | unless ref($vals) eq 'ARRAY'; | ||||||||||
| 46 | #$self->param(-name=>$tag,-value=>\@vals); | ||||||||||
| 47 | 0 | $self->param(-name=>$tag,-value=>$vals);# look ma, it's *already* a reference! | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 1 | 1; | |||||||||
| 51 | __END__ | ||||||||||