Branch Coverage

blib/lib/CGI/Simple.pm
Criterion Covered Total %
branch 323 468 69.0


line true false branch
25 7 73 unless defined $USE_CGI_PM_DEFAULTS
29 15 65 if ($USE_CGI_PM_DEFAULTS)
35 7 58 unless defined $DISABLE_UPLOADS
39 6 59 unless defined $POST_MAX
43 7 58 unless defined $NO_UNDEF_PARAMS
47 7 58 unless defined $USE_PARAM_SEMICOLONS
51 7 58 unless defined $HEADERS_ONCE
55 7 58 unless defined $NPH
59 7 58 unless defined $DEBUG
63 7 58 unless defined $NO_NULL
67 7 58 unless defined $FATAL
76 8 15 unless defined $DISABLE_UPLOADS
77 8 15 unless defined $POST_MAX
78 8 15 unless defined $NO_UNDEF_PARAMS
79 8 15 unless defined $USE_PARAM_SEMICOLONS
80 8 15 unless defined $HEADERS_ONCE
81 8 15 unless defined $NPH
82 8 15 unless defined $DEBUG
83 8 15 unless defined $NO_NULL
84 8 15 unless defined $FATAL
109 7 20 if /^-default/i
110 2 18 if /^-no.?upload/i
111 2 16 if /^-upload/i
112 2 14 if /^-unique.?header/i
113 3 11 if /^-nph/i
114 2 9 if /^-no.?debug/i
115 0 2 defined $1 ? :
2 7 if /^-debug(\d)?/i
116 2 5 if /^-newstyle.?url/i
117 2 3 if /^-oldstyle.?url/i
118 3 0 if /^-no.?undef.?param/i
119 0 0 if /^-carp/i
120 0 0 if /^-croak/i
139 2 575 unless defined $decode
147 2 428 unless defined $encode
174 0 78 if $self->_mod_perl
196 0 0 unless $mp
198 0 0 if ($mp == 2) { }
210 0 0 if (defined $mod_perl::VERSION)
212 0 0 if ($mod_perl::VERSION >= 2) { }
221 0 0 if (defined $r)
222 0 0 unless exists $ENV{'REQUEST_METHOD'}
233 0 0 if (defined $r)
249 50 28 if (not defined $init) { }
5 23 elsif (ref($init) =~ /HASH/i) { }
7 16 elsif (UNIVERSAL::isa($init, 'GLOB')) { }
1 15 elsif (ref $init eq 'CGI::Simple') { }
269 0 1 if ($@) { }
287 0 50 if ($method eq 'POST' and $$self{'.globals'}{'POST_MAX'} != -1 and $length > $$self{'.globals'}{'POST_MAX'})
296 0 0 unless sysread STDIN, my $buffer, 4096
303 0 50 if ($length and $type =~ m[^multipart/form-data]i) { }
3 47 elsif ($method eq 'POST') { }
45 2 elsif ($method eq 'GET' or $method eq 'HEAD') { }
305 0 0 if ($length != $got_length)
311 3 0 if ($length)
317 0 2 unless sysread STDIN, my $buffer, 4096
321 0 3 unless ($length == length $data)
327 0 45 $$self{'.mod_perl'} ? :
334 0 2 unless ($$self{'.globals'}{'DEBUG'} and $data = $self->read_from_cmdline)
341 2 48 unless ($data)
353 0 107 unless defined $data
354 9 98 unless ($data =~ /[&=;]/)
361 0 279 unless defined $param
362 4 275 unless defined $value
370 4 338 unless defined $param and defined $value
371 250 88 if $$self{'.globals'}{'NO_NULL'}
372 23 315 if $overwrite
373 161 177 unless exists $$self{$param}
374 45 293 ref $value ? :
377 4 384 if $value eq '' and $$self{'.globals'}{'NO_UNDEF_PARAMS'}
379 292 92 if $$self{'.globals'}{'NO_NULL'}
381 165 219 unless ($$self{'.fieldnames'}{$param})
391 0 13 unless defined $data
393 9 4 if $$self{'.globals'}{'NO_NULL'}
402 0 0 unless ($boundary)
409 0 0 unless $ENV{'HTTP_USER_AGENT'} =~ /MSIE\s+3\.0[12];\s*Mac/i
420 0 0 unless sysread STDIN, my $buffer, 4096
432 0 0 unless $data =~ /^([\x20-\x7E\x80-\xFF\x09$CRLF]+?$CRLF$CRLF)/o
440 0 0 if (defined $filename)
448 0 0 if $fh
449 0 0 if $size
455 0 0 unless $data =~ s/^\Q$header\E(.*?)$CRLF(?=$boundary)//s
459 0 0 unless ($data =~ /^$boundary/)
468 0 0 if $data =~ s/.*?$CRLF(?=$boundary$CRLF)//s
480 0 0 if ($$self{'.globals'}{'DISABLE_UPLOADS'}) { }
0 0 elsif ($filename) { }
484 0 0 if $@
486 0 0 unless $fh
494 0 0 if $fh
498 0 0 unless sysread STDIN, $data, 4096
502 0 0 unless ($data)
510 0 0 if ("$buffer$data" =~ /$boundary/)
516 0 0 if $fh
520 0 0 if $fh
529 0 46 if $CRLF
530 11 35 unless ($$self{'.crlf'})
533 0 11 $OS =~ /VMS/i ? :
545 125 310 unless (defined $param)
547 115 10 $$self{'.parameters'} ? :
550 279 31 unless (@p)
551 12 267 unless exists $$self{$param}
552 211 56 wantarray ? :
554 12 19 if ($param =~ /^-name$/i and @p == 1)
555 4 8 unless exists $$self{$p[0]}
556 2 6 wantarray ? :
561 12 7 if $param =~ /^-name$/i
563 4 15 ref $p[0] eq 'ARRAY' ? :
565 6 13 wantarray ? :
589 2 4 defined $param && $param =~ /^-name$/i ? :
591 2 4 unless defined $param
592 0 4 unless exists $$self{$param}
599 0 14 unless $ENV{'QUERY_STRING'}
608 4 4 ref $values[0] eq 'ARRAY' ? :
8 8 if @values
612 16 0 defined $$self{'keywords'} ? :
624 10 4 wantarray ? :
627 14 0 $_[1] ? :
635 4 0 ref $$q{$p} eq 'ARRAY' ? :
645 4 20 unless defined $param
649 8 12 if $param =~ /^-name$/i
651 4 16 defined $p[0] && ref $p[0] ? :
658 4 8 unless defined $param
659 0 8 $param =~ /^-name$/i ? :
663 0 8 unless defined $$self{$param}
682 8 9 unless ($filename)
683 0 8 if $writefile
687 4 4 $$self{'.filehandles'} ? :
690 1 8 unless ($ENV{'CONTENT_TYPE'} =~ m[^multipart/form-data]i)
703 0 8 if not $fh and defined $$self{'.upload_fields'}{$filename}
708 4 4 if ($fh) { }
710 2 2 unless $writefile
712 0 2 unless (open OUT, ">$writefile")
736 0 0 wantarray ? :
742 0 0 unless ($ENV{'CONTENT_TYPE'} =~ m[^multipart/form-data]i)
748 0 0 unless $filename
749 0 0 if $info =~ /mime/i
762 0 196 unless defined $value
768 24 26 $$self{'.globals'}{'USE_PARAM_SEMICOLONS'} ? :
776 2 0 if defined $ENV{'QUERY_STRING'} and $ENV{'REQUEST_METHOD'} eq 'POST'
788 7 28 if $pair eq '='
796 0 4 unless ($fh and fileno $fh)
820 2 16 if $newlinestoo
852 16 12 unless (defined $value)
853 2 14 unless $$self{'.cookies'}
855 0 16 unless $$self{'.cookies'}
858 4 12 unless $name
862 8 4 exists $$self{'.cookies'}{$name} ? :
868 0 12 unless $name
872 8 4 if $domain
873 8 4 if $path
874 8 4 if $expires
875 8 4 if $secure
881 8 4 if (defined $key)
882 2 6 unless ($$self{'.raw_cookies'})
898 0 30 if $$self{'.header_printed'}++ and $$self{'.globals'}{'HEADERS_ONCE'}
923 0 12 unless my($header, $value) = /([^ \r\n\t=]+)="?(.+?)"?$/
927 10 20 unless defined $type
928 14 16 if $type and $type =~ m[^text/] and not $type =~ /\bcharset\b/
933 10 20 if $nph
934 10 20 if $nph
935 12 18 if $status
936 0 30 if $target
938 0 30 if ($p3p)
939 0 0 if ref $p3p eq 'ARRAY'
944 2 28 if ($cookie)
945 0 2 ref $cookie eq 'ARRAY' ? :
947 2 0 ref $cookie eq 'CGI::Simple::Cookie' ? :
951 2 0 if $cs
957 6 24 if $self->no_cache
959 8 22 if $expires
962 14 16 if defined $expires or $cookie or $nph
964 8 22 if $self->cache or $self->no_cache
965 2 28 if $attachment
969 24 6 if $type
974 0 30 if ($$self{'.mod_perl'} and not $nph)
985 2 32 if defined $value
992 2 54 if defined $value
1013 0 10 if $target
1014 0 10 if $cookie
1017 0 10 if $cookie
1054 0 0 unless my($header, $value) = /([^\s=]+)="?(.+?)"?$/
1072 2 0 if ($_[0]{'.globals'}{'DEBUG'} == 1 and @ARGV) { }
0 0 elsif ($_[0]{'.globals'}{'DEBUG'} == 2) { }
1084 2 0 "@words" =~ /=/ ? :
1098 5 5 if ($err)
1100 0 5 $$self{'.globals'}{'FATAL'} == 0 ? :
0 5 $$self{'.globals'}{'FATAL'} == 1 ? :
1111 12 5 if ref $_[0] eq 'CGI::Simple'
1119 4 2 @_ ? :
1127 3 3 wantarray ? :
6 0 if defined $_[0]
1137 8 2 server_port() != 80 ? :
1147 2 2 $ENV{'QUERY_STRING'} ? :
1153 2 0 ref $_[0] ? :
1171 0 0 @_ ? :
1184 2 2 if defined $_[1]
1197 6 10 unless $global
1198 2 8 if defined $value
1209 0 2 unless $ENV{'REMOTE_ADDR'}
1212 0 2 unless $ENV{'REMOTE_HOST'} or $ENV{'REMOTE_ADDR'}
1218 0 58 unless $ENV{'SCRIPT_NAME'} or $0
1219 0 30 unless $ENV{'SERVER_NAME'}
1220 0 60 unless $ENV{'SERVER_PORT'}
1221 0 22 unless $ENV{'SERVER_PROTOCOL'}
1222 0 12 unless $ENV{'SERVER_SOFTWARE'}
1225 0 2 unless $ENV{'HTTP_FROM'} or $ENV{'REMOTE_IDENT'}
1230 4 2 $match ? :
1243 4 46 if (defined $info) { }
6 40 elsif (not defined $$self{'.path_info'}) { }
1244 2 2 if not $info =~ m[^/]
1247 6 0 defined $ENV{'PATH_INFO'} ? :
1251 0 6 if defined $ENV{'SERVER_SOFTWARE'} and $ENV{'SERVER_SOFTWARE'} =~ /IIS/
1264 0 40 unless $type
1267 4 4 unless $search
1268 2 2 if $prefs{$search}
1272 0 2 unless $pref =~ /\*/
1275 2 0 if $search =~ /$pat/
1283 30 4 if (defined $parameter)
1285 4 26 if $parameter =~ /^HTTP/
1286 26 0 if $parameter
1293 2 6 unless $parameter
1295 2 4 if $parameter =~ /^HTTPS/
1302 2 22 if uc $ENV{'HTTPS'} eq 'ON'
1303 2 20 if $self->server_port == 443
1320 18 24 if $base or not $relative || $absolute
1323 18 24 if ($full) { }
18 6 elsif ($relative) { }
6 0 elsif ($absolute) { }
1327 0 18 if ($vh) { }
1332 18 0 unless lc $protocol eq 'http' and $port == 80 or lc $protocol eq 'https' and $port == 443
1336 0 18 if $base
1343 24 18 if $path_info and defined $path
1344 18 24 if $query and $self->query_string
1345 0 42 unless defined $url