Branch Coverage

blib/lib/Cookie/Jar.pm
Criterion Covered Total %
branch 177 676 26.1


line true false branch
20 0 2 if (exists $ENV{'MOD_PERL'} and $MOD_PERL = $ENV{'MOD_PERL'} =~ m[^mod_perl/(\d+\.[\d\.]+)])
55 0 8 if @_ and @_ % 2
72 0 8 if $req
78 0 0 if ($file and $file->exists and not $file->is_empty)
88 0 0 unless exists $type2sub->{$type}
91 0 0 if ($encrypt) { }
93 0 0 unless &$loader($self, $file, "algo", $self->algo, "key", $self->secret)
100 0 0 unless &$loader($self, $file)
110 13 3 if (scalar @_ == 1) { }
3 0 elsif (scalar @_) { }
123 3 13 if (ref $this eq 'HASH') { }
3 10 elsif (not ref $this) { }
0 10 elsif (not $self->_is_object($this) or $self->_is_object($this) and not $this->isa('Cookie')) { }
126 0 3 unless defined $this
142 3 0 if exists $ref->{'secure'}
144 0 3 if exists $ref->{'samesite'}
145 0 3 if exists $ref->{'httponly'}
147 0 3 unless defined $this
156 0 16 unless $this->name
159 16 0 unless exists $idx->{$key}
170 0 5 unless &Scalar::Util::blessed($req)
171 0 5 unless $req->can("uri") and $req->can("header")
174 0 5 unless ($scheme =~ /^https?\z/)
179 5 0 if ($host = $req->header('Host')) { }
189 5 0 $scheme eq 'https' ? :
191 0 5 if ($uri->can('epath')) { }
200 0 5 unless CORE::length $path
201 5 0 unless defined $port and CORE::length $port
204 0 5 if index($path, "%") != -1
206 0 5 if ($self->_is_ip($host)) { }
214 0 5 unless defined $res
215 0 5 if (not CORE::length $res or $res and not $res->domain->length)
238 0 0 unless ($c->host_only and $root eq $c->domain or not $c->host_only and $host eq $c->domain)
243 1 11 if (index($path, $c->path) != 0) { }
0 11 elsif (not $is_secure and $c->secure) { }
1 10 elsif ($c->expires and $c->expires < $now) { }
0 10 elsif ($c->port and $c->port != $port) { }
270 0 2 unless $b->path->length <=> $a->path->length
279 5 0 if (@values)
281 0 5 if (my $old = $req->header("Cookie"))
295 0 0 if ($resp)
297 0 0 unless $self->_is_object($resp)
298 0 0 unless $resp->can("header")
305 0 0 if ($c->discard)
310 0 0 if ($resp) { }
0 0 elsif ($r) { }
325 0 0 if (@values)
327 0 0 wantarray ? :
332 0 0 if $r or $resp
347 1 0 if (scalar @_ == 1 and $self->_is_a($_[0], 'Cookie')) { }
355 1 2 if (&Scalar::Util::refaddr($this) eq $addr)
358 1 0 if (exists $idx->{$key})
361 0 1 if (!&Scalar::Util::reftype($idx->{$key}) eq "ARRAY")
367 1 0 if (&Scalar::Util::refaddr($idx->{$key}[$j]) eq $addr)
374 1 0 if scalar @{$idx->{$key};} == 0
388 0 0 unless defined $name and CORE::length "$name"
391 0 0 unless exists $idx->{$key}
392 0 0 unless $self->_is_array($idx->{$key})
396 0 0 unless ref $c and $self->_is_a($c, "Cookie")
400 0 0 if (&Scalar::Util::refaddr($ref->[$i]) eq $addr)
417 0 2 if ref $code ne "CODE"
422 0 6 unless ref $c and $self->_is_a($c, "Cookie")
429 0 6 if (not defined $rv) { }
6 0 elsif ($rv) { }
438 0 6 if ($@)
455 0 0 unless defined $name and CORE::length $name
457 0 0 defined $c ? :
465 0 4 unless &Scalar::Util::blessed($resp)
467 4 0 if ($self->_is_a($resp, 'HTTP::Response')) { }
0 0 elsif ($resp->can('uri') and $resp->can('header')) { }
470 0 4 unless $resp->request
483 0 4 unless $all->length
484 0 4 unless $uri
486 4 0 if ($host = $resp->header('Host') || $resp->request && ($host = $resp->request->header('Host'))) { }
499 0 4 if ($uri->can('epath')) { }
508 0 4 unless CORE::length $path
509 4 0 unless defined $port and CORE::length $port
511 0 4 if ($self->_is_ip($host)) { }
519 0 4 unless (defined $res)
524 4 0 $res ? :
532 2 2 if (CORE::length $o->param('expires')) { }
0 2 elsif (CORE::length $o->param('max-age')) { }
535 0 2 if ($dt) { }
549 0 4 if ($o->param('domain')) { }
562 0 0 if (CORE::length $c_dom >= CORE::length $root and $c_dom eq $host || $host =~ /\.$c_dom$/) { }
576 4 0 if ($root) { }
587 3 1 if (defined $o->param('path') and CORE::length $o->param('path')) { }
595 1 0 if ($path eq '/' or substr($path, -1, 1) eq '/') { }
605 4 0 if defined $port
606 0 4 if $o->param("httponly")
607 0 4 if $o->param("secure")
608 0 4 if $o->param("samesite")
611 1 3 if (scalar @old)
613 1 0 if $old[0]->created_on
624 0 4 unless $self->add($c)
637 0 1 unless CORE::length "$str"
640 1 0 if (defined $opts->{'host'} and CORE::length $opts->{'host'})
643 0 1 if ($self->_is_ip($host)) { }
651 0 1 unless (defined $res)
656 1 0 $res ? :
665 1 0 if (CORE::length $o->param('expires')) { }
0 0 elsif (CORE::length $o->param('max-age')) { }
668 0 1 if ($dt) { }
682 0 1 if ($o->param('domain')) { }
698 1 0 if ($root) { }
709 1 0 if (defined $o->param('path') and CORE::length $o->param('path')) { }
717 0 0 if ($opts->{'path'} eq '/' or substr($opts->{'path'}, -1, 1) eq '/') { }
727 1 0 if defined $opts->{'port'} and $self->_is_integer($opts->{'port'})
728 0 1 if $o->param("httponly")
729 0 1 if $o->param("secure")
730 0 1 if $o->param("samesite")
740 1 0 unless exists $opts->{'store'}
745 0 1 if ($r) { }
1 0 elsif ($opts->{'request'} and $self->_is_object($opts->{'request'}) and $opts->{'request'}->can('header')) { }
0 0 elsif (CORE::length $opts->{'string'}) { }
754 0 0 if ($o->jar_status =~ /^(?:Missing input data|Success)$/) { }
775 0 0 if ($@)
793 1 0 unless (scalar @$cookies)
804 1 0 if ($opts->{'store'})
808 0 3 unless $self->add($c)
823 0 8 if (scalar @_ == 1 and $self->_is_a($_[0], 'Cookie')) { }
4 4 elsif (scalar @_ == 1 and ref $_[0] eq 'HASH') { }
4 0 elsif (scalar @_ > 0 and scalar @_ <= 3) { }
843 0 8 unless defined $name and CORE::length $name
850 0 8 if (exists $idx->{$key})
852 0 0 wantarray ? :
864 13 5 unless $c_name eq $name
867 0 5 unless (defined $host and CORE::length $host)
873 4 0 if (defined $c_host and $host eq $c_host || index(reverse($host), reverse(".$c_host")) == 0)
876 1 3 if (defined $path and CORE::length "$path") { }
878 1 0 if (index($path, $c_path) == 0)
890 4 4 if (scalar @found)
892 1 3 wantarray ? :
897 1 3 if (exists $idx->{$name})
899 0 1 wantarray ? :
910 5 0 unless exists $opts->{'sort'}
912 0 5 unless defined $host and CORE::length $host
918 12 0 if $dom eq $host or $opts->{'with_subdomain'} and $host =~ /\.$dom$/
921 5 0 if ($opts->{'sort'}) { }
940 17 8 if (scalar @_ == 1 and $self->_is_a($_[0], 'Cookie')) { }
950 0 8 if ref $name and $self->_is_a($name, ref $self)
952 0 25 unless CORE::length $name
953 22 3 if defined $host and CORE::length $host
974 0 1 unless defined $json
976 0 1 unless (CORE::length $json)
981 0 1 if ($opts->{'decrypt'})
985 0 0 unless defined $key and CORE::length "$key"
986 0 0 unless defined $algo and CORE::length "$algo"
987 0 0 unless $self->_load_class("Crypt::Misc", {"version", "0.074"})
997 0 0 if ($@)
1011 0 1 if ($@)
1015 0 1 if (ref $hash ne "HASH")
1021 0 1 if ref $repo ne "ARRAY"
1024 0 3 if (not exists $def->{'name'} && exists $def->{'value'}) { }
0 3 elsif (not defined $def->{'name'} && CORE::length $def->{'name'}) { }
1037 0 3 unless $self->add($c)
1054 0 1 $opts->{'decrypt'} ? :
0 1 unless $f->open("<", {"binmode", $opts->{'decrypt'} ? "raw" : "utf-8"})
1057 3 1 if (/^Set-Cookie3:[[:blank:]\h]*(.*?)$/) { }
1067 0 1 if ($opts->{'decrypt'}) { }
1073 0 0 unless defined $key and CORE::length "$key"
1074 0 0 unless defined $algo and CORE::length "$algo"
1075 0 0 unless $self->_load_class("Crypt::Misc", {"version", "0.074"})
1085 0 0 if ($@)
1091 0 0 unless $io->line($code, "chomp", 1, "auto_next", 1)
1096 0 1 unless $f->line($code, "chomp", 1, "auto_next", 1)
1117 0 0 exists $opts->{'use_dbi'} && defined $opts->{'use_dbi'} && $opts->{'use_dbi'} ? :
1136 0 0 if ($requires_dbi or not $opts->{'use_dbi'} || $opts->{'sqlite'})
1145 0 0 if $@
1147 0 0 if (defined $dbi_error and exists $opts->{'use_dbi'} and defined $opts->{'use_dbi'} and $opts->{'use_dbi'}) { }
0 0 elsif (not defined $dbi_error) { }
1182 0 0 unless $tbl_check->execute
1185 0 0 unless ($found)
1191 0 0 unless $sth->execute
1198 0 0 if ($@)
1200 0 0 if ($requires_dbi) { }
1206 0 0 if $self->_warnings_is_enabled
1215 0 0 unless (scalar @$cookies or $requires_dbi)
1218 0 0 if (exists $opts->{'sqlite'} and defined $opts->{'sqlite'} and CORE::length $opts->{'sqlite'}) { }
1220 0 0 if (not -e $opts->{'sqlite'}) { }
0 0 elsif (not -x $opts->{'sqlite'}) { }
1234 0 0 unless (defined $bin)
1242 0 0 unless open my $fh, "-|", $sqlite_bin, "$sqldb", $sql
1256 0 0 unless $self->add({"name", $name, "value", $value, "domain", $domain, "path", $path, "expires", $expires, "secure", $secure, "http_only", $http_only, "same_site", $same_site, "accessed_on", $accessed, "created_on", $created})
1279 0 0 unless $f->open
1283 0 0 lc $secure eq 'true' ? :
1285 0 0 if substr($domain, 1, 1) eq "."
1294 0 0 unless $f->line(sub {
1303 0 15 unless $opts->{'name'}
1306 0 15 unless defined $c
1307 0 15 unless $c->apply($opts)
1316 0 0 unless $self->_is_a($jar, "Cookie::Jar")
1318 0 0 unless $jar->can("do")
1327 0 0 if defined $error
1329 0 0 if ($self->_is_object($c))
1331 0 0 if ($self->_is_a($c, 'Cookie')) { }
0 0 elsif ($c->can('name') and $c->can('value') and $c->can('domain') and $c->can('path') and $c->can('expires') and $c->can('max_age') and $c->can('port') and $c->can('secure') and $c->can('same_site') and $c->can('http_only')) { }
1333 0 0 if ($opts->{'overwrite'}) { }
1365 0 0 if (not defined $new) { }
1368 0 0 if $opts->{'die'}
1372 0 0 if ($opts->{'overwrite'}) { }
1386 0 0 if $opts->{'die'}
1390 0 0 if defined $error
1402 2 21 unless defined $raw and CORE::length $raw
1410 0 60 unless defined $v
1426 0 0 if ($c->is_expired)
1428 0 0 unless $self->delete($c)
1443 0 0 unless defined $c
1444 0 0 unless $self->_is_a($c, "Cookie")
1446 0 0 if (defined $old) { }
1448 0 0 unless $self->_is_a($old, "Cookie")
1449 0 0 if ($c->name ne $old->name or $c->domain ne $old->domain or $c->path ne $old->path)
1457 0 0 if (exists $idx->{$key})
1461 0 0 if (&Scalar::Util::refaddr($idx->{$key}[$i]) eq $addr)
1470 0 0 if (&Scalar::Util::refaddr($ref->[$i]) eq $addr)
1481 0 0 exists $idx->{$key} ? :
1487 0 0 if (&Scalar::Util::refaddr($ref->[$j]) eq $addr)
1513 0 1 if $opts->{'format'} eq "lwp"
1529 0 1 if ($@)
1551 0 1 if ($@)
1556 0 1 $opts->{'encrypt'} ? :
0 1 unless $f->open(">", {"binmode", $opts->{'encrypt'} ? "raw" : "utf8"})
1558 0 1 if ($opts->{'encrypt'}) { }
1560 0 0 unless $self->_load_class("Crypt::Misc", {"version", "0.074"})
1588 0 1 unless $file
1593 0 1 if ($opts->{'encrypt'})
1595 0 0 unless $self->_load_class("Crypt::Misc", {"version", "0.074"})
1601 0 1 if ($opts->{'encrypt'}) { }
1607 0 1 unless $io->print("#LWP-Cookies-1.0\n")
1613 0 0 if $c->discard and $opts->{'skip_discard'}
1614 0 0 if $c->expires and $c->expires < $now and $opts->{'skip_expired'}
1616 3 0 if CORE::length $vals->{'path'}
1622 0 3 if defined $vals->{'port'} and CORE::length $vals->{'port'}
1623 3 0 if defined $vals->{'path_spec'} and $vals->{'path_spec'}
1624 3 0 if defined $vals->{'secure'} and $vals->{'secure'}
1625 0 3 if defined $vals->{'secure'} and $vals->{'expires'}
1626 0 0 if defined $vals->{'discard'} and $vals->{'discard'}
1627 0 3 if (defined $vals->{'comment'} and CORE::length $vals->{'comment'})
1632 0 3 if defined $vals->{'commentURL'} and CORE::length $vals->{'commentURL'}
1634 0 3 if ($opts->{'encrypt'}) { }
1640 0 3 unless $io->print("Set-Cookie3: ", $hv->as_string, "\n")
1643 0 1 if ($opts->{'encrypt'})
1669 0 0 exists $opts->{'use_dbi'} && defined $opts->{'use_dbi'} && $opts->{'use_dbi'} ? :
1716 0 0 if $c->discard and $opts->{'skip_discard'}
1717 0 0 if $c->expires and $c->expires < $now and $opts->{'skip_expired'}
1730 0 0 $c->expires ? :
0 0 $c->secure ? :
0 0 $c->same_site->lc eq 'strict' ? :
0 0 $c->http_only ? :
0 0 $c->accessed_on ? :
0 0 $c->created_on ? :
1732 0 0 if ($can_do_upsert)
1735 0 0 $c->expires ? :
1736 0 0 $c->secure ? :
1737 0 0 $c->same_site->lc eq 'strict' ? :
1738 0 0 $c->http_only ? :
1739 0 0 $c->accessed_on ? :
1740 0 0 $c->created_on ? :
1765 0 0 if ($opts->{'log_sql'})
1773 0 0 if ($requires_dbi or not $opts->{'use_dbi'} || $opts->{'sqlite'})
1781 0 0 if $@
1783 0 0 if (defined $dbi_error and exists $opts->{'use_dbi'} and defined $opts->{'use_dbi'} and $opts->{'use_dbi'}) { }
0 0 elsif (not defined $dbi_error) { }
1803 0 0 if ($opts->{'log_sql'})
1805 0 0 unless ($log_file->open(">>", {"binmode", "utf-8", "autoflush", 1}))
1826 0 0 if ($db_file_exists)
1834 0 0 if ($table_moz_cookies_exists)
1837 0 0 if ($opts->{'overwrite'}) { }
1867 0 0 if (not exists $fields->{$f}) { }
0 0 elsif ($core_fields->{$f}{'type'} ne uc $fields->{$f}{'type'}) { }
1876 0 0 if (scalar @$missing or scalar @$bad_datatype)
1889 0 0 if (not $table_moz_cookies_exists) { }
1902 0 0 $sql_v >= $req_v ? :
1904 0 0 if ($can_do_upsert) { }
1919 0 0 if ($opts->{'rollback'})
1930 0 0 unless $insert_sth->bind_param($i + 1, $c->[$i][0], $c->[$i][1])
1936 0 0 if ($@)
1940 0 0 if ($opts->{'rollback'})
1950 0 0 if ($@)
1952 0 0 if ($requires_dbi) { }
1959 0 0 if $self->_warnings_is_enabled
1962 0 0 if defined $err
1968 0 0 if (defined $dbi_error and not $requires_dbi or exists $opts->{'sqlite'} and defined $opts->{'sqlite'} and CORE::length $opts->{'sqlite'})
1972 0 0 if (exists $opts->{'sqlite'} and defined $opts->{'sqlite'} and CORE::length $opts->{'sqlite'}) { }
1974 0 0 if (not -e $opts->{'sqlite'}) { }
0 0 elsif (not -x $opts->{'sqlite'}) { }
1988 0 0 unless (defined $bin)
1998 0 0 unless open $fh, "-|", $sqlite_bin, "--version"
2002 0 0 if (defined $sqlite_version)
2011 0 0 unless open $fh, "-|", $sqlite_bin, "$sqldb", "SELECT name FROM sqlite_master WHERE type IN ('table') AND name IS 'moz_cookies'"
2020 0 0 unless open $fh, "|-", $sqlite_bin, "--bail", "$sqldb"
2023 0 0 if ($opts->{'log_sql'})
2025 0 0 unless print $fh ".trace $log_file\n"
2028 0 0 if ($table_moz_cookies_exists and $opts->{'overwrite'})
2030 0 0 unless print $fh "DROP TABLE IF EXISTS moz_cookies;\n"
2035 0 0 if ($opts->{'rollback'})
2037 0 0 unless print $fh "BEGIN TRANSACTION;\n"
2041 0 0 if (not $table_moz_cookies_exists) { }
2044 0 0 unless print $fh "$create_table_sql;\n"
2050 0 0 defined $sql_v && $sql_v >= $req_v ? :
2052 0 0 if ($can_do_upsert) { }
2068 0 0 if ($$core_fields{$ref->[2]}{'constant'} eq 'SQL_INTEGER') { }
2082 0 0 unless (print $fh "$sql;\n")
2084 0 0 if ($opts->{'rollback'})
2092 0 0 if ($opts->{'rollback'})
2094 0 0 unless print $fh "END TRANSACTION;\n"
2100 0 0 if ($opts->{'log_sql'} and defined $log_file and $log_file->opened)
2116 0 0 unless $opts->{'file'}
2125 0 0 if $c->discard and $opts->{'skip_discard'}
2126 0 0 if $c->expires and $c->expires < $now and $opts->{'skip_expired'}
2128 0 0 $c->domain->substr(1, 1) eq '.' ? :
2130 0 0 $c->secure ? :
2151 0 4 unless $c->name->length
2152 0 4 unless &Scalar::Util::blessed($c)
2153 0 4 unless $c->can("as_string")
2156 0 4 if ($r) { }
4 0 elsif ($opts->{'response'} and $self->_is_object($opts->{'response'}) and $opts->{'response'}->can('header')) { }
2180 0 0 unless defined $key and CORE::length "$key"
2181 0 0 unless defined $algo and CORE::length "$algo"
2182 0 0 unless $self->_load_class("Crypt::Mode::CBC", {"version", "0.074"})
2183 0 0 unless $self->_load_class("Bytes::Random::Secure")
2190 0 0 if ($@)
2194 0 0 unless $crypt
2197 0 0 unless $self->_load_class($class)
2205 0 0 if ($@)
2209 0 0 if CORE::length $key < $key_len
2211 0 0 if (defined $iv and CORE::length "$iv") { }
2213 0 0 if (CORE::length $iv != $block_len)
2224 0 0 if ($@)
2250 0 0 $x eq '2F' || $x eq '25' ? :
2260 0 8 if ($self->autosave and $file)
2271 0 0 unless (exists $type2sub->{$type})
2273 0 0 if $self->_warnings_is_enabled
2279 0 0 if ($encrypt) { }
2285 0 0 unless (&$unloader($self, $file, "algo", $self->algo, "key", $self->secret))
2286 0 0 if $self->_warnings_is_enabled
2292 0 0 unless (&$unloader($self, $file))
2293 0 0 if $self->_warnings_is_enabled