Branch Coverage

blib/lib/CGI/Simple.pm
Criterion Covered Total %
branch 376 506 74.3


line true false branch
24 13 94 unless defined $USE_CGI_PM_DEFAULTS
28 43 64 if ($USE_CGI_PM_DEFAULTS)
34 12 52 unless defined $DISABLE_UPLOADS
38 12 52 unless defined $POST_MAX
42 13 51 unless defined $NO_UNDEF_PARAMS
46 13 51 unless defined $USE_PARAM_SEMICOLONS
51 0 64 if $PARAM_UTF8
54 13 51 unless defined $HEADERS_ONCE
58 13 51 unless defined $NPH
62 13 51 unless defined $DEBUG
66 13 51 unless defined $NO_NULL
70 13 51 unless defined $FATAL
79 12 54 unless defined $DISABLE_UPLOADS
80 12 54 unless defined $POST_MAX
81 12 54 unless defined $NO_UNDEF_PARAMS
82 12 54 unless defined $USE_PARAM_SEMICOLONS
83 12 54 unless defined $HEADERS_ONCE
84 12 54 unless defined $NPH
85 12 54 unless defined $DEBUG
86 12 54 unless defined $NO_NULL
87 12 54 unless defined $FATAL
88 8 58 unless defined $PARAM_UTF8
114 11 20 if /^-default/i
115 2 18 if /^-no.?upload/i
116 2 16 if /^-upload/i
117 2 14 if /^-unique.?header/i
118 3 11 if /^-nph/i
119 2 9 if /^-no.?debug/i
120 0 2 defined $1 ? :
2 7 if /^-debug(\d)?/i
121 2 5 if /^-newstyle.?url/i
122 2 3 if /^-oldstyle.?url/i
123 3 0 if /^-no.?undef.?param/i
124 0 0 if /^-carp/i
125 0 0 if /^-croak/i
144 2 620 unless defined $decode
152 2 566 unless defined $encode
181 0 105 if ($self->_mod_perl)
182 0 0 if ($init)
210 0 0 unless $mp
213 0 0 if $req
216 0 0 if ($mp == 2) { }
230 0 0 if (defined $mod_perl::VERSION)
232 0 0 if ($mod_perl::VERSION >= 2.0) { }
243 0 0 if (defined $r)
244 0 0 unless exists $ENV{'REQUEST_METHOD'}
256 0 0 if (defined $r)
266 73 32 if (not defined $init) { }
8 24 elsif (ref($init) =~ /HASH/i) { }
2 22 elsif (UNIVERSAL::isa($init, 'GLOB')) { }
1 21 elsif (ref $init eq 'CGI::Simple') { }
292 0 1 if ($@) { }
306 4 12 unless defined $len
307 0 16 if ($self->{'.mod_perl'}) { }
326 0 16 if ($method eq 'POST' || $method eq 'PUT' and $self->{'.globals'}{'POST_MAX'} != -1 and $length > $self->{'.globals'}{'POST_MAX'})
335 0 0 unless &_internal_read($self, $handle, \my $buffer)
342 4 71 if ($length and $type =~ m[^multipart/form-data]i) { }
12 59 elsif ($method eq 'POST' or $method eq 'PUT') { }
54 5 elsif ($method eq 'GET' or $method eq 'HEAD') { }
344 0 4 if ($length != $got_length)
353 12 0 if ($length)
360 0 0 unless &_internal_read($self, $handle, \my $buffer)
364 0 12 unless ($length == length $data)
370 6 6 if (not $type =~ m[^application/x-www-form-urlencoded]) { }
383 0 54 $self->{'.mod_perl'} ? :
388 3 2 unless ($self->{'.globals'}{'DEBUG'} and $data = $self->read_from_cmdline)
394 0 2 unless ($data)
408 0 102 unless defined $data
409 12 90 unless ($data =~ /[&=;]/)
416 0 300 unless defined $param
417 4 296 unless defined $value
425 4 385 unless defined $param and defined $value
426 235 150 if $self->{'.globals'}{'NO_NULL'}
427 29 356 if $overwrite
428 200 185 unless exists $self->{$param}
429 51 334 ref $value ? :
433 4 4 if $value eq "" and $self->{'.globals'}{'NO_UNDEF_PARAMS'}
435 277 0 if $self->{'.globals'}{'NO_NULL'} and $param ne "PUTDATA" and $param ne "POSTDATA"
437 0 0 if $self->{'.globals'}{'PARAM_UTF8'} and $param ne "PUTDATA" and $param ne "POSTDATA"
439 207 230 unless ($self->{'.fieldnames'}{$param})
449 0 16 unless defined $data
451 9 7 if $self->{'.globals'}{'NO_NULL'}
463 4 0 unless exists $ENV{'HTTP_USER_AGENT'} and $ENV{'HTTP_USER_AGENT'} =~ /MSIE\s+3\.0[12];\s*Mac/i
470 0 4 unless my $handle = shift()
475 3 1 if $boundary
485 0 4 unless &_internal_read($self, $handle, \my $buffer)
489 1 3 unless ($boundary)
491 0 1 unless $data =~ /^(.*)$CRLF/o
495 0 1 unless ($boundary)
511 0 8 unless $data =~ /^([\x20-\x7E\x80-\xFF\x09$CRLF]+?$CRLF$CRLF)/o
518 4 4 if (defined $filename)
526 1 3 if $fh
527 4 0 if $size
533 0 4 unless $data =~ s/^\Q$header\E(.*?)$CRLF(?=$boundary)//s
536 1 3 unless ($data =~ /^$boundary/)
545 0 1 if $data =~ s/.*?$CRLF(?=$boundary$CRLF)//s
557 3 1 if ($self->{'.globals'}{'DISABLE_UPLOADS'}) { }
1 0 elsif ($filename) { }
562 0 1 if $@
564 0 1 unless $fh
572 1 3 if $fh
576 0 0 unless &_internal_read($self, \*STDIN, \$data)
580 0 0 unless ($data)
588 0 0 if ("$buffer$data" =~ /$boundary/)
594 0 0 if $fh
598 1 3 if $fh
607 0 88 if $CRLF
608 17 71 unless ($self->{'.crlf'})
611 0 17 $OS =~ /VMS/i ? :
623 141 394 unless (defined $param)
625 129 12 $self->{'.parameters'} ? :
628 354 40 unless (@p)
629 15 339 unless exists $self->{$param}
630 263 76 wantarray ? :
632 15 25 if ($param =~ /^-name$/i and @p == 1)
633 4 11 unless exists $$self{$p[0]}
634 2 9 wantarray ? :
639 15 10 if $param =~ /^-name$/i
641 4 21 ref $p[0] eq 'ARRAY' ? :
643 6 19 wantarray ? :
657 2 4 defined $param && $param =~ /^-name$/i ? :
659 2 4 unless defined $param
660 0 4 unless exists $self->{$param}
667 0 17 unless $ENV{'QUERY_STRING'}
676 4 4 ref $values[0] eq 'ARRAY' ? :
8 11 if @values
680 19 0 defined $self->{'keywords'} ? :
687 10 7 if (wantarray) { }
701 7 0 $_[1] ? :
705 0 6 unless defined $v
711 7 0 if (ref $q->{$p} eq 'ARRAY') { }
721 4 20 unless defined $param
725 8 12 if $param =~ /^-name$/i
727 4 16 defined $p[0] && ref $p[0] ? :
734 4 11 unless defined $param
735 0 11 $param =~ /^-name$/i ? :
739 0 11 unless defined $self->{$param}
758 8 9 unless ($filename)
759 0 8 if $writefile
762 4 4 $self->{'.filehandles'} ? :
765 1 8 unless ($ENV{'CONTENT_TYPE'} =~ m[^multipart/form-data]i)
780 0 8 if not $fh and defined $self->{'.upload_fields'}{$filename}
782 4 4 if ($fh) { }
784 2 2 unless $writefile
787 0 2 unless (open $out, ">", $writefile)
811 0 0 wantarray ? :
817 0 3 unless ($ENV{'CONTENT_TYPE'} =~ m[^multipart/form-data]i)
823 0 3 unless $filename
824 3 0 if $info =~ /mime/i
837 0 265 unless defined $value
842 42 28 $self->{'.globals'}{'USE_PARAM_SEMICOLONS'} ? :
852 2 0 if defined $ENV{'QUERY_STRING'} and $ENV{'REQUEST_METHOD'} eq "POST"
864 0 0 if $pair eq "="
872 0 4 unless ($fh and fileno $fh)
898 2 16 if $newlinestoo
935 16 12 unless (defined $value)
937 2 14 unless $self->{'.cookies'}
938 0 16 unless $self->{'.cookies'}
941 4 12 unless $name
946 8 4 exists $self->{'.cookies'}{$name} ? :
951 0 12 unless $name
955 8 4 if $domain
956 8 4 if $path
957 8 4 if $expires
958 8 4 if $secure
959 8 4 if $httponly
960 0 12 if $samesite
966 8 4 if (defined $key)
967 2 6 unless ($self->{'.raw_cookies'})
984 0 41 if $self->{'.header_printed'}++ and $self->{'.globals'}{'HEADERS_ONCE'}
1008 94 384 if (defined $header)
1016 11 83 if ($header =~ /$ALL_POSSIBLE_CRLF/)
1018 0 11 if length $header > 72
1035 0 16 unless my($header, $value) = /([^ \r\n\t=]+)=\"?(.+?)\"?$/s
1039 14 27 unless defined $type
1040 20 15 if $type and $type =~ m[^text/] and not $type =~ /\bcharset\b/
1045 14 27 if $nph
1046 14 27 if $nph
1047 12 29 if $status
1048 0 41 if $target
1050 0 41 if ($p3p)
1051 0 0 if ref $p3p eq "ARRAY"
1056 3 38 if ($cookie)
1057 1 2 ref $cookie eq 'ARRAY' ? :
1059 2 2 ref $cookie eq 'CGI::Simple::Cookie' ? :
1063 4 0 if $cs
1069 6 35 if $self->no_cache
1071 8 33 if $expires
1074 11 22 if defined $expires or $cookie or $nph
1076 8 33 if $self->cache or $self->no_cache
1077 2 39 if $attachment
1081 35 6 if $type
1085 0 41 if ($self->{'.mod_perl'} and not $nph)
1096 2 43 if defined $value
1103 2 76 if defined $value
1125 0 13 if $target
1126 0 13 if $cookie
1129 0 13 if $cookie
1144 6 4 unless ($boundary)
1172 0 0 unless my($header, $value) = /([^\s=]+)=\"?(.+?)\"?$/
1190 2 0 if ($_[0]{'.globals'}{'DEBUG'} == 1 and @ARGV) { }
0 0 elsif ($_[0]{'.globals'}{'DEBUG'} == 2) { }
1203 2 0 join($", @words) =~ /=/ ? :
1217 11 7 if ($err)
1220 0 11 $self->{'.globals'}{'FATAL'} == 0 ? :
0 11 if ($self->{'.globals'}{'FATAL'} == 1) { }
1230 12 5 if ref $_[0] eq "CGI::Simple"
1239 4 2 @_ ? :
1247 3 3 wantarray ? :
6 0 if defined $_[0]
1257 8 2 server_port() != 80 ? :
1269 2 2 $ENV{'QUERY_STRING'} ? :
1273 2 0 ref $_[0] ? :
1292 0 0 @_ ? :
1304 2 2 if defined $_[1]
1317 6 10 unless $global
1318 2 8 if defined $value
1329 0 2 unless $ENV{'REMOTE_ADDR'}
1332 0 0 unless $ENV{'REMOTE_HOST'} or $ENV{'REMOTE_ADDR'}
1338 0 2 unless $ENV{'SCRIPT_NAME'} or $0
1339 2 36 unless $ENV{'SERVER_NAME'}
1340 4 72 unless $ENV{'SERVER_PORT'}
1341 2 28 unless $ENV{'SERVER_PROTOCOL'}
1342 0 16 unless $ENV{'SERVER_SOFTWARE'}
1345 0 0 unless $ENV{'HTTP_FROM'} or $ENV{'REMOTE_IDENT'}
1352 4 2 $match ? :
1363 4 66 if (defined $info) { }
10 56 elsif (not defined $self->{'.path_info'}) { }
1364 2 2 unless $info =~ m[^/]
1369 9 1 defined $ENV{'PATH_INFO'} ? :
1374 0 10 if defined $ENV{'SERVER_SOFTWARE'} and $ENV{'SERVER_SOFTWARE'} =~ /IIS/
1385 0 40 unless $type
1388 4 4 unless $search
1389 2 2 if $prefs{$search}
1393 3 2 unless $pref =~ /\*/
1396 2 0 if $search =~ /$pat/
1404 41 4 if (defined $parameter)
1406 4 37 if $parameter =~ /^HTTP/
1407 37 0 if $parameter
1414 2 6 unless $parameter
1416 2 4 if $parameter =~ /^HTTPS/
1423 2 30 if uc $ENV{'HTTPS'} eq "ON"
1424 2 28 if $self->server_port == 443
1442 26 36 if $base or not $relative || $absolute
1445 26 36 if ($full) { }
27 9 elsif ($relative) { }
9 0 elsif ($absolute) { }
1449 0 26 if ($vh) { }
1455 24 0 unless lc $protocol eq "http" and $port == 80 or lc $protocol eq "https" and $port == 443
1459 0 26 if $base
1468 35 27 if $path_info and defined $path
1469 24 38 if $query and $self->query_string
1470 0 62 unless defined $url