Branch Coverage

blib/lib/CGI/Simple.pm
Criterion Covered Total %
branch 363 506 71.7


line true false branch
24 11 94 unless defined $USE_CGI_PM_DEFAULTS
28 43 62 if ($USE_CGI_PM_DEFAULTS)
34 11 51 unless defined $DISABLE_UPLOADS
38 10 52 unless defined $POST_MAX
42 11 51 unless defined $NO_UNDEF_PARAMS
46 11 51 unless defined $USE_PARAM_SEMICOLONS
51 0 62 if $PARAM_UTF8
54 11 51 unless defined $HEADERS_ONCE
58 11 51 unless defined $NPH
62 11 51 unless defined $DEBUG
66 11 51 unless defined $NO_NULL
70 11 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 103 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) { }
243 0 0 if (defined $r)
244 0 0 unless exists $ENV{'REQUEST_METHOD'}
256 0 0 if (defined $r)
266 71 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 2 12 unless defined $len
307 0 14 if ($self->{'.mod_perl'}) { }
326 0 14 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 2 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 2 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 384 unless defined $param and defined $value
426 234 150 if $self->{'.globals'}{'NO_NULL'}
427 29 355 if $overwrite
428 199 185 unless exists $self->{$param}
429 51 333 ref $value ? :
433 4 4 if $value eq "" and $self->{'.globals'}{'NO_UNDEF_PARAMS'}
435 276 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 206 230 unless ($self->{'.fieldnames'}{$param})
449 0 16 unless defined $data
451 9 7 if $self->{'.globals'}{'NO_NULL'}
463 2 0 unless exists $ENV{'HTTP_USER_AGENT'} and $ENV{'HTTP_USER_AGENT'} =~ /MSIE\s+3\.0[12];\s*Mac/i
470 0 2 unless my $handle = shift()
475 2 0 if $boundary
485 0 2 unless &_internal_read($self, $handle, \my $buffer)
489 0 2 unless ($boundary)
491 0 0 unless $data =~ /^(.*)$CRLF/o
495 0 0 unless ($boundary)
511 0 7 unless $data =~ /^([\x20-\x7E\x80-\xFF\x09$CRLF]+?$CRLF$CRLF)/o
518 3 4 if (defined $filename)
526 0 3 if $fh
527 3 0 if $size
533 0 4 unless $data =~ s/^\Q$header\E(.*?)$CRLF(?=$boundary)//s
536 0 2 unless ($data =~ /^$boundary/)
545 0 0 if $data =~ s/.*?$CRLF(?=$boundary$CRLF)//s
557 3 0 if ($self->{'.globals'}{'DISABLE_UPLOADS'}) { }
0 0 elsif ($filename) { }
562 0 0 if $@
564 0 0 unless $fh
572 0 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 0 3 if $fh
607 0 78 if $CRLF
608 15 63 unless ($self->{'.crlf'})
611 0 15 $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 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 34 if $self->{'.header_printed'}++ and $self->{'.globals'}{'HEADERS_ONCE'}
1007 87 321 if (defined $header)
1014 6 81 if ($header =~ /$CRLF/)
1016 0 6 if length $header > 72
1033 0 14 unless my($header, $value) = /([^ \r\n\t=]+)=\"?(.+?)\"?$/s
1037 12 27 unless defined $type
1038 18 15 if $type and $type =~ m[^text/] and not $type =~ /\bcharset\b/
1043 14 25 if $nph
1044 14 25 if $nph
1045 12 27 if $status
1046 0 39 if $target
1048 0 39 if ($p3p)
1049 0 0 if ref $p3p eq "ARRAY"
1054 3 36 if ($cookie)
1055 1 2 ref $cookie eq 'ARRAY' ? :
1057 2 2 ref $cookie eq 'CGI::Simple::Cookie' ? :
1061 4 0 if $cs
1067 6 33 if $self->no_cache
1069 8 31 if $expires
1072 11 20 if defined $expires or $cookie or $nph
1074 8 31 if $self->cache or $self->no_cache
1075 2 37 if $attachment
1079 33 6 if $type
1083 0 39 if ($self->{'.mod_perl'} and not $nph)
1094 2 41 if defined $value
1101 2 72 if defined $value
1123 0 13 if $target
1124 0 13 if $cookie
1127 0 13 if $cookie
1142 6 4 unless ($boundary)
1170 0 0 unless my($header, $value) = /([^\s=]+)=\"?(.+?)\"?$/
1188 2 0 if ($_[0]{'.globals'}{'DEBUG'} == 1 and @ARGV) { }
0 0 elsif ($_[0]{'.globals'}{'DEBUG'} == 2) { }
1201 2 0 join($", @words) =~ /=/ ? :
1215 11 5 if ($err)
1218 0 11 $self->{'.globals'}{'FATAL'} == 0 ? :
0 11 $self->{'.globals'}{'FATAL'} == 1 ? :
1228 12 5 if ref $_[0] eq "CGI::Simple"
1237 4 2 @_ ? :
1245 3 3 wantarray ? :
6 0 if defined $_[0]
1255 8 2 server_port() != 80 ? :
1267 2 2 $ENV{'QUERY_STRING'} ? :
1271 2 0 ref $_[0] ? :
1290 0 0 @_ ? :
1302 2 2 if defined $_[1]
1315 6 10 unless $global
1316 2 8 if defined $value
1327 0 2 unless $ENV{'REMOTE_ADDR'}
1330 0 0 unless $ENV{'REMOTE_HOST'} or $ENV{'REMOTE_ADDR'}
1336 0 2 unless $ENV{'SCRIPT_NAME'} or $0
1337 2 36 unless $ENV{'SERVER_NAME'}
1338 4 72 unless $ENV{'SERVER_PORT'}
1339 2 28 unless $ENV{'SERVER_PROTOCOL'}
1340 0 16 unless $ENV{'SERVER_SOFTWARE'}
1343 0 0 unless $ENV{'HTTP_FROM'} or $ENV{'REMOTE_IDENT'}
1350 4 2 $match ? :
1361 4 66 if (defined $info) { }
10 56 elsif (not defined $self->{'.path_info'}) { }
1362 2 2 unless $info =~ m[^/]
1367 9 1 defined $ENV{'PATH_INFO'} ? :
1372 0 10 if defined $ENV{'SERVER_SOFTWARE'} and $ENV{'SERVER_SOFTWARE'} =~ /IIS/
1383 0 40 unless $type
1386 4 4 unless $search
1387 2 2 if $prefs{$search}
1391 3 2 unless $pref =~ /\*/
1394 2 0 if $search =~ /$pat/
1402 41 4 if (defined $parameter)
1404 4 37 if $parameter =~ /^HTTP/
1405 37 0 if $parameter
1412 2 6 unless $parameter
1414 2 4 if $parameter =~ /^HTTPS/
1421 2 30 if uc $ENV{'HTTPS'} eq "ON"
1422 2 28 if $self->server_port == 443
1440 26 36 if $base or not $relative || $absolute
1443 26 36 if ($full) { }
27 9 elsif ($relative) { }
9 0 elsif ($absolute) { }
1447 0 26 if ($vh) { }
1453 24 0 unless lc $protocol eq "http" and $port == 80 or lc $protocol eq "https" and $port == 443
1457 0 26 if $base
1466 35 27 if $path_info and defined $path
1467 24 38 if $query and $self->query_string
1468 0 62 unless defined $url