Branch Coverage

blib/lib/Cookie/Jar.pm
Criterion Covered Total %
branch 178 678 26.2


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 builtin::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 (builtin::refaddr($this) eq $addr)
358 1 0 if (exists $idx->{$key})
361 0 1 if (builtin::reftype($idx->{$key}) ne "ARRAY")
367 1 0 if (builtin::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 (builtin::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 builtin::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 if $Cookie::Jar::COOKIES_DEBUG
625 0 4 unless $self->add($c)
638 0 1 unless CORE::length "$str"
641 1 0 if (defined $opts->{'host'} and CORE::length $opts->{'host'})
644 0 1 if ($self->_is_ip($host)) { }
652 0 1 unless (defined $res)
657 1 0 $res ? :
666 1 0 if (CORE::length $o->param('expires')) { }
0 0 elsif (CORE::length $o->param('max-age')) { }
669 0 1 if ($dt) { }
683 0 1 if ($o->param('domain')) { }
699 1 0 if ($root) { }
710 1 0 if (defined $o->param('path') and CORE::length $o->param('path')) { }
718 0 0 if ($opts->{'path'} eq '/' or substr($opts->{'path'}, -1, 1) eq '/') { }
728 1 0 if defined $opts->{'port'} and $self->_is_integer($opts->{'port'})
729 0 1 if $o->param("httponly")
730 0 1 if $o->param("secure")
731 0 1 if $o->param("samesite")
741 1 0 unless exists $opts->{'store'}
746 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'}) { }
755 0 0 if ($o->jar_status =~ /^(?:Missing input data|Success)$/) { }
776 0 0 if ($@)
794 1 0 unless (scalar @$cookies)
805 1 0 if ($opts->{'store'})
809 0 3 unless $self->add($c)
824 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) { }
844 0 8 unless defined $name and CORE::length $name
851 0 8 if (exists $idx->{$key})
853 0 0 wantarray ? :
865 13 5 unless $c_name eq $name
868 0 5 unless (defined $host and CORE::length $host)
874 4 0 if (defined $c_host and $host eq $c_host || index(reverse($host), reverse(".$c_host")) == 0)
877 1 3 if (defined $path and CORE::length "$path") { }
879 1 0 if (index($path, $c_path) == 0)
891 4 4 if (scalar @found)
893 1 3 wantarray ? :
898 1 3 if (exists $idx->{$name})
900 0 1 wantarray ? :
911 5 0 unless exists $opts->{'sort'}
913 0 5 unless defined $host and CORE::length $host
919 12 0 if $dom eq $host or $opts->{'with_subdomain'} and $host =~ /\.$dom$/
922 5 0 if ($opts->{'sort'}) { }
941 17 8 if (scalar @_ == 1 and $self->_is_a($_[0], 'Cookie')) { }
951 0 8 if ref $name and $self->_is_a($name, ref $self)
953 0 25 unless CORE::length $name
954 22 3 if defined $host and CORE::length $host
975 0 1 unless defined $json
977 0 1 unless (CORE::length $json)
982 0 1 if ($opts->{'decrypt'})
986 0 0 unless defined $key and CORE::length "$key"
987 0 0 unless defined $algo and CORE::length "$algo"
988 0 0 unless $self->_load_class("Crypt::Misc", {"version", "0.074"})
998 0 0 if ($@)
1012 0 1 if ($@)
1016 0 1 if (ref $hash ne "HASH")
1022 0 1 if ref $repo ne "ARRAY"
1025 0 3 if (not exists $def->{'name'} && exists $def->{'value'}) { }
0 3 elsif (not defined $def->{'name'} && CORE::length $def->{'name'}) { }
1038 0 3 unless $self->add($c)
1055 0 1 $opts->{'decrypt'} ? :
0 1 unless $f->open("<", {"binmode", $opts->{'decrypt'} ? "raw" : "utf-8"})
1058 3 1 if (/^Set-Cookie3:[[:blank:]\h]*(.*?)$/) { }
1068 0 1 if ($opts->{'decrypt'}) { }
1074 0 0 unless defined $key and CORE::length "$key"
1075 0 0 unless defined $algo and CORE::length "$algo"
1076 0 0 unless $self->_load_class("Crypt::Misc", {"version", "0.074"})
1086 0 0 if ($@)
1092 0 0 unless $io->line($code, "chomp", 1, "auto_next", 1)
1097 0 1 unless $f->line($code, "chomp", 1, "auto_next", 1)
1118 0 0 exists $opts->{'use_dbi'} && defined $opts->{'use_dbi'} && $opts->{'use_dbi'} ? :
1137 0 0 if ($requires_dbi or not $opts->{'use_dbi'} || $opts->{'sqlite'})
1146 0 0 if $@
1148 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) { }
1183 0 0 unless $tbl_check->execute
1186 0 0 unless ($found)
1192 0 0 unless $sth->execute
1199 0 0 if ($@)
1201 0 0 if ($requires_dbi) { }
1207 0 0 if $self->_warnings_is_enabled
1216 0 0 unless (scalar @$cookies or $requires_dbi)
1219 0 0 if (exists $opts->{'sqlite'} and defined $opts->{'sqlite'} and CORE::length $opts->{'sqlite'}) { }
1221 0 0 if (not -e $opts->{'sqlite'}) { }
0 0 elsif (not -x $opts->{'sqlite'}) { }
1235 0 0 unless (defined $bin)
1243 0 0 unless open my $fh, "-|", $sqlite_bin, "-noheader", "-separator", "|", "$sqldb", $sql
1257 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})
1280 0 0 unless $f->open
1284 0 0 lc $secure eq 'true' ? :
1286 0 0 if substr($domain, 1, 1) eq "."
1295 0 0 unless $f->line(sub {
1304 0 15 unless $opts->{'name'}
1307 0 15 unless defined $c
1308 0 15 unless $c->apply($opts)
1317 0 0 unless $self->_is_a($jar, "Cookie::Jar")
1319 0 0 unless $jar->can("do")
1328 0 0 if defined $error
1330 0 0 if ($self->_is_object($c))
1332 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')) { }
1334 0 0 if ($opts->{'overwrite'}) { }
1366 0 0 if (not defined $new) { }
1369 0 0 if $opts->{'die'}
1373 0 0 if ($opts->{'overwrite'}) { }
1387 0 0 if $opts->{'die'}
1391 0 0 if defined $error
1403 2 21 unless defined $raw and CORE::length $raw
1411 0 60 unless defined $v
1427 0 0 if ($c->is_expired)
1429 0 0 unless $self->delete($c)
1444 0 0 unless defined $c
1445 0 0 unless $self->_is_a($c, "Cookie")
1447 0 0 if (defined $old) { }
1449 0 0 unless $self->_is_a($old, "Cookie")
1450 0 0 if ($c->name ne $old->name or $c->domain ne $old->domain or $c->path ne $old->path)
1458 0 0 if (exists $idx->{$key})
1462 0 0 if (builtin::refaddr($idx->{$key}[$i]) eq $addr)
1471 0 0 if (builtin::refaddr($ref->[$i]) eq $addr)
1482 0 0 exists $idx->{$key} ? :
1488 0 0 if (builtin::refaddr($ref->[$j]) eq $addr)
1514 0 1 if $opts->{'format'} eq "lwp"
1530 1 0 if ($@)
1552 0 1 if ($@)
1557 0 1 $opts->{'encrypt'} ? :
0 1 unless $f->open(">", {"binmode", $opts->{'encrypt'} ? "raw" : "utf8"})
1559 0 1 if ($opts->{'encrypt'}) { }
1561 0 0 unless $self->_load_class("Crypt::Misc", {"version", "0.074"})
1589 0 1 unless $file
1594 0 1 if ($opts->{'encrypt'})
1596 0 0 unless $self->_load_class("Crypt::Misc", {"version", "0.074"})
1602 0 1 if ($opts->{'encrypt'}) { }
1608 0 1 unless $io->print("#LWP-Cookies-1.0\n")
1614 0 0 if $c->discard and $opts->{'skip_discard'}
1615 0 0 if $c->expires and $c->expires < $now and $opts->{'skip_expired'}
1617 3 0 if CORE::length $vals->{'path'}
1623 0 3 if defined $vals->{'port'} and CORE::length $vals->{'port'}
1624 3 0 if defined $vals->{'path_spec'} and $vals->{'path_spec'}
1625 3 0 if defined $vals->{'secure'} and $vals->{'secure'}
1626 0 3 if defined $vals->{'secure'} and $vals->{'expires'}
1627 0 0 if defined $vals->{'discard'} and $vals->{'discard'}
1628 0 3 if (defined $vals->{'comment'} and CORE::length $vals->{'comment'})
1633 0 3 if defined $vals->{'commentURL'} and CORE::length $vals->{'commentURL'}
1635 0 3 if ($opts->{'encrypt'}) { }
1641 0 3 unless $io->print("Set-Cookie3: ", $hv->as_string, "\n")
1644 0 1 if ($opts->{'encrypt'})
1670 0 0 exists $opts->{'use_dbi'} && defined $opts->{'use_dbi'} && $opts->{'use_dbi'} ? :
1717 0 0 if $c->discard and $opts->{'skip_discard'}
1718 0 0 if $c->expires and $c->expires < $now and $opts->{'skip_expired'}
1731 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 ? :
1733 0 0 if ($can_do_upsert)
1736 0 0 $c->expires ? :
1737 0 0 $c->secure ? :
1738 0 0 $c->same_site->lc eq 'strict' ? :
1739 0 0 $c->http_only ? :
1740 0 0 $c->accessed_on ? :
1741 0 0 $c->created_on ? :
1766 0 0 if ($opts->{'log_sql'})
1774 0 0 if ($requires_dbi or not $opts->{'use_dbi'} || $opts->{'sqlite'})
1782 0 0 if $@
1784 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) { }
1804 0 0 if ($opts->{'log_sql'})
1806 0 0 unless ($log_file->open(">>", {"binmode", "utf-8", "autoflush", 1}))
1827 0 0 if ($db_file_exists)
1835 0 0 if ($table_moz_cookies_exists)
1838 0 0 if ($opts->{'overwrite'}) { }
1868 0 0 if (not exists $fields->{$f}) { }
0 0 elsif ($core_fields->{$f}{'type'} ne uc $fields->{$f}{'type'}) { }
1877 0 0 if (scalar @$missing or scalar @$bad_datatype)
1890 0 0 if (not $table_moz_cookies_exists) { }
1903 0 0 $sql_v >= $req_v ? :
1905 0 0 if ($can_do_upsert) { }
1920 0 0 if ($opts->{'rollback'})
1931 0 0 unless $insert_sth->bind_param($i + 1, $c->[$i][0], $c->[$i][1])
1937 0 0 if ($@)
1941 0 0 if ($opts->{'rollback'})
1951 0 0 if ($@)
1953 0 0 if ($requires_dbi) { }
1960 0 0 if $self->_warnings_is_enabled
1963 0 0 if defined $err
1969 0 0 if (defined $dbi_error and not $requires_dbi or exists $opts->{'sqlite'} and defined $opts->{'sqlite'} and CORE::length $opts->{'sqlite'})
1973 0 0 if (exists $opts->{'sqlite'} and defined $opts->{'sqlite'} and CORE::length $opts->{'sqlite'}) { }
1975 0 0 if (not -e $opts->{'sqlite'}) { }
0 0 elsif (not -x $opts->{'sqlite'}) { }
1989 0 0 unless (defined $bin)
1999 0 0 unless open $fh, "-|", $sqlite_bin, "--version"
2003 0 0 if (defined $sqlite_version)
2012 0 0 unless open $fh, "-|", $sqlite_bin, "$sqldb", "SELECT name FROM sqlite_master WHERE type IN ('table') AND name IS 'moz_cookies'"
2021 0 0 unless open $fh, "|-", $sqlite_bin, "--bail", "$sqldb"
2024 0 0 if ($opts->{'log_sql'})
2026 0 0 unless print $fh ".trace $log_file\n"
2029 0 0 if ($table_moz_cookies_exists and $opts->{'overwrite'})
2031 0 0 unless print $fh "DROP TABLE IF EXISTS moz_cookies;\n"
2036 0 0 if ($opts->{'rollback'})
2038 0 0 unless print $fh "BEGIN TRANSACTION;\n"
2042 0 0 if (not $table_moz_cookies_exists) { }
2045 0 0 unless print $fh "$create_table_sql;\n"
2051 0 0 defined $sql_v && $sql_v >= $req_v ? :
2053 0 0 if ($can_do_upsert) { }
2069 0 0 if ($$core_fields{$ref->[2]}{'constant'} eq 'SQL_INTEGER') { }
2083 0 0 unless (print $fh "$sql;\n")
2085 0 0 if ($opts->{'rollback'})
2093 0 0 if ($opts->{'rollback'})
2095 0 0 unless print $fh "END TRANSACTION;\n"
2101 0 0 if ($opts->{'log_sql'} and defined $log_file and $log_file->opened)
2117 0 0 unless $opts->{'file'}
2126 0 0 if $c->discard and $opts->{'skip_discard'}
2127 0 0 if $c->expires and $c->expires < $now and $opts->{'skip_expired'}
2129 0 0 $c->domain->substr(1, 1) eq '.' ? :
2131 0 0 $c->secure ? :
2152 0 4 unless $c->name->length
2153 0 4 unless builtin::blessed($c)
2154 0 4 unless $c->can("as_string")
2157 0 4 if ($r) { }
4 0 elsif ($opts->{'response'} and $self->_is_object($opts->{'response'}) and $opts->{'response'}->can('header')) { }
2181 0 0 unless defined $key and CORE::length "$key"
2182 0 0 unless defined $algo and CORE::length "$algo"
2183 0 0 unless $self->_load_class("Crypt::Mode::CBC", {"version", "0.074"})
2184 0 0 unless $self->_load_class("Bytes::Random::Secure")
2191 0 0 if ($@)
2195 0 0 unless $crypt
2198 0 0 unless $self->_load_class($class)
2206 0 0 if ($@)
2210 0 0 if CORE::length $key < $key_len
2212 0 0 if (defined $iv and CORE::length "$iv") { }
2214 0 0 if (CORE::length $iv != $block_len)
2225 0 0 if ($@)
2252 0 0 $x eq '2F' || $x eq '25' ? :
2262 0 8 if ($self->autosave and $file)
2273 0 0 unless (exists $type2sub->{$type})
2275 0 0 if $self->_warnings_is_enabled
2281 0 0 if ($encrypt) { }
2287 0 0 unless (&$unloader($self, $file, "algo", $self->algo, "key", $self->secret))
2288 0 0 if $self->_warnings_is_enabled
2294 0 0 unless (&$unloader($self, $file))
2295 0 0 if $self->_warnings_is_enabled