Branch Coverage

lib/Mail/SpamAssassin/Util.pm
Criterion Covered Total %
branch 230 534 43.0


line true false branch
84 0 44 if (&RUNNING_ON_WINDOWS())
92 0 0 if $_[0] & 127
108 1 1 unless ($displayed_path++)
113 0 6 if (-f $fname)
114 0 0 if (-x $fname) { }
135 81 26 if $cleaned_taint_path++
136 0 26 unless am_running_in_taint_mode()
140 0 26 if (&RUNNING_ON_WINDOWS())
151 0 96 unless $dir
155 96 0 if $dir =~ /^(.+)$/
159 3 93 if (not 'File::Spec'->file_name_is_absolute($dir)) { }
0 93 elsif (not @stat = stat $dir) { }
0 93 elsif (not -d _) { }
0 93 elsif (($stat[2] & 2) != 0) { }
190 150 26 if defined $AM_TAINTED
192 26 0 if ($] >= 5.008) { }
200 0 0 unless opendir TAINT, $d
202 0 0 unless closedir TAINT
205 0 0 unless (defined $blank and $blank)
211 0 0 unless eval "1 || $blank"
213 26 0 $AM_TAINTED ? :
236 0 313 unless defined $path
237 0 313 if $path eq ""
246 313 0 if ($path =~ /$re/) { }
258 0 0 unless defined $host
259 0 0 if $host eq ""
266 0 0 if (length $host <= 255 and $host =~ /^[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?(?:\.[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?)*$/i) { }
288 13243 97 if (not ref $_[0]) { }
292 0 13243 unless defined $_[0]
299 14 83 if ($r eq 'ARRAY') { }
1 82 elsif ($r eq 'HASH') { }
82 0 elsif ($r eq 'SCALAR' or $r eq 'REF') { }
302 0 14 if wantarray
306 1 0 if ($arg == \%ENV) { }
309 0 34 unless (defined $v)
319 0 1 if wantarray
336 0 1184 unless defined $v
342 0 1184 unless defined $t
354 0 739 unless defined $host
360 0 739 if length $host > 253
365 48 691 unless $cnt > 1
368 13 1701 if length $label < 1
369 0 1701 if length $label > 63
372 26 1675 unless $label =~ /^[a-z0-9_](?:[a-z0-9_-]*[a-z0-9_])?$/
374 1276 399 if ($cnt == 2 or $cnt == 1)
375 28 1248 if index($label, "_") != -1
393 0 0 if (not defined $stat) { }
0 0 elsif (WIFEXITED($stat)) { }
0 0 elsif (WIFSTOPPED($stat)) { }
401 0 0 $sig == 15 ? :
0 0 $sig == 9 ? :
0 0 $sig == 6 ? :
0 0 $sig == 2 ? :
0 0 $sig == 1 ? :
407 0 0 if (defined $errno)
408 0 0 if 0 + $errno != 0 or $errno ne "" and $errno ne 0
421 0 0 if (!defined($errno) || $errno == 0 and WIFEXITED($exit_status))
423 0 0 if (not @success) { }
0 0 elsif (grep {$_ == $j;} @success) { }
500 0 2 if defined $LOCALTZ
520 26 0 if (s/ (\d+) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) / /i) { }
0 0 elsif (s/ (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) +(\d+) \d+:\d+:\d+ (\d{4}) / /i) { }
0 0 elsif (s/ (\d+) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{2,3}) / /i) { }
532 26 0 if (defined $yyyy)
533 0 26 if (length $yyyy == 2 and $yyyy < 50) { }
0 26 elsif (length $yyyy != 4) { }
543 26 0 if (s/ (\d?\d):(\d\d)(:(\d\d))? / /)
548 26 0 if (s/ ([-+]\d{4}) / /) { }
0 0 elsif (s/\b([A-Z]{2,4}(?:-DST)?)\b/ / and exists $TZ{$1}) { }
559 26 0 if (exists $MONTH{$mon})
566 1 25 if ($ss > 59)
571 1 25 if ($mm > 59)
576 1 25 if ($hh > 23)
582 9 17 if ($mmm == 4 or $mmm == 6 or $mmm == 9 or $mmm == 11) { }
8 9 elsif ($mmm == 2) { }
586 0 8 !($yyyy % 4) && ($yyyy % 100 || !($yyyy % 400)) ? :
588 5 21 if ($dd > $max_dd)
592 1 4 if ($mmm > 12)
600 0 26 if ($yyyy > 2037) { }
0 26 elsif ($yyyy < 1970) { }
613 0 26 unless (eval {
614 0 0 $@ ne '' ? :
619 26 0 if ($tzoff =~ /([-+])(\d\d)(\d\d)$/)
622 13 13 if ($1 eq '-') { }
0 13 elsif ($time < $tzoff) { }
682 192 173 if $first
696 3254 584 if ($pos_mod != 0 and $overflow == 0)
702 3716 122 if ($len <= $length) { }
738 7 0 if (length($_) % 4 == 0 and m[^(?:[A-Za-z0-9+/=]{2,}={0,2})$]s)
747 0 7 if (defined $decoded_length)
759 0 0 if length($_) % 4 == 1
764 0 0 length $_ >= 84 ? :
766 0 0 if defined $decoded_length and length $out >= $decoded_length
771 0 0 if (defined $decoded_length)
812 70 26 if (defined &Mail::SpamAssassin::Util::_getpwuid_wrapper)
817 26 0 if (not &RUNNING_ON_WINDOWS()) { }
823 0 26 if (not $sts) { }
824 0 0 $@ ne '' ? :
855 0 0 unless defined $str
857 0 0 if ($str =~ /\b(
864 0 0 if (defined $1)
880 0 9 if defined $hostname
893 68 9 if defined $fq_hostname
896 9 0 unless ($fq_hostname =~ /\./)
900 0 9 if @names
916 0 0 unless defined $ip1
917 0 0 unless defined $ip2
918 0 0 unless $ip1 =~ /^(\d+\.\d+\.)/
919 0 0 unless $ip2 =~ /^(\d+\.\d+\.)/
920 0 0 if ($b1 eq $b2)
933 0 0 unless defined $ip1
934 0 0 unless defined $ip2
935 0 0 unless $ip1 =~ /^(\d+\.\d+\.\d+\.)/
936 0 0 unless $ip2 =~ /^(\d+\.\d+\.\d+\.)/
937 0 0 if ($b1 eq $b2)
956 108 8 if ($ip =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\z/) { }
0 8 elsif (not $ip =~ /:/ && $ip =~ /^[0-9a-fA-F:.]{2,}\z/) { }
0 8 elsif (not 'NetAddr::IP'->can('full6')) { }
965 8 0 if (defined $ip_obj)
990 0 42 if utf8::is_utf8($qname)
994 0 0 $1 <= 255 ? :
0 0 length $1 == 1 ? :
1033 29 334 if defined $boundary
1043 0 363 if (not $name and $ct =~ /\b(?:file)?name\*0\s*=/i)
1068 271 92 if (not $ct or $ct =~ /^text\b/ and not $ct =~ m[^text/(?:x-vcard|calendar|html)$])
1081 363 0 wantarray ? :
1094 83 88 if (/\%[0-9a-fA-F]{2}/) { }
1099 83 0 unless (/(20|7f|[0189a-fA-F][0-9a-fA-F])/i)
1109 0 0 if push @encoded, $1
1112 0 9 if (wantarray) { }
1141 0 30 unless $mod =~ /^[\w:]+$/
1142 10 20 if (eval "require " . $mod . "; 1;")
1168 0 0 unless defined $file and $file ne ""
1170 0 0 if ($args->{'create_exclusive'})
1171 0 0 if (sysopen my $fh, $file, 192)
1175 0 0 if $! == 17
1180 0 0 unless (utime undef, undef, $file)
1201 0 65 am_running_on_windows() ? :
1204 0 65 unless defined $tmpdir and $tmpdir ne ""
1207 0 65 unless opendir my $dh, $tmpdir
1208 0 65 unless closedir $dh
1220 65 0 if (sysopen $tmpfh, $reportfile, 194, 384)
1221 0 65 unless binmode $tmpfh
1227 0 0 if ($tmpfh)
1228 0 0 unless (close $tmpfh)
1235 0 0 if $errno == 17
1242 0 65 unless ($tmpfh)
1264 0 0 unless ($tmpdir)
1284 0 0 if (mkdir $reportpath, 448)
1289 0 0 if ($!{'EEXIST'})
1300 0 0 unless $tmppath
1334 0 537 if length $uri <= 1 or $uri =~ m[^(?:[#?&]|/(?!/))]
1340 41 496 if ($nuri =~ /^mailto:/i or $nuri =~ /^[^:]*\@/)
1343 0 41 if ($nuri =~ /^([^\@]+\@[^?]+)\?/)
1346 0 41 if ($nuri =~ /^([^\@]+\@[^?&]+)\&/)
1350 8 33 if ($nuri =~ tr/%02// and $nuri =~ /^(?:mailto:)?(?:\%20)*([^\@]+\@[^?&%]+)/)
1355 0 41 if ($nuri =~ /^[^?&]*<([^\@>]+\@[^>]+)>/)
1373 9 487 if ($nuri =~ /%[0-9a-fA-F]{2}/)
1379 139 357 unless ($nuri =~ /^[-_a-z0-9]+:/i)
1380 2 137 if ($nuri =~ /^ftp\./) { }
1400 156 340 if ($nuri ne $uri)
1405 476 20 if ($nuri =~ m[^(https?://)([^\@/?#]*\@)?([^/?#:]+)((?::(\d*))?.*)$]i)
1407 11 465 defined $2 ? :
1408 35 441 defined $5 ? :
1411 452 24 if ($port eq '') { }
1412 443 9 $proto eq 'http://' ? :
1416 24 0 if ($proto eq 'http://') { }
0 0 elsif ($rest_noport =~ s/^:443\b//) { }
1417 19 5 if ($rest_noport =~ s/^:80\b//)
1436 5 471 if ($host =~ s/(?: \xE3\x80\x82 | \xEF\xBC\x8E | \xEF\xBD\xA1 |
1440 0 5 if $rest_noport
1449 0 476 if ($host =~ tr/\000- //d)
1461 5 2424 if ("$proto$host$rest" =~ /$re/)
1462 0 5 unless defined $1 and index($1, ".") != -1
1470 471 5 unless ($found_redirector_match)
1473 6 465 if ($rest =~ m[(https?:/{0,2}[^&#]+)]i and index($1, ".") != -1)
1486 0 476 if ($host =~ s/^[^\@]+\@//gs)
1494 1 475 if ($host =~ s/[^0-9A-Za-z]+$//)
1505 37 439 if ($host =~ /^
6 433 elsif ($host =~ /^0x[0-9a-f]+$/i) { }
20 413 elsif ($host =~ /^[0-9]+$/) { }
12 405 elsif ($proto eq 'http://' and $auth eq '' and $host ne 'localhost' and $port eq '80' and $host =~ /^(?:www\.)?([^.]+)$/) { }
1561 10 0 if defined $time and $time
1576 8 2 if (@rcvd)
1577 0 8 if ($rcvd[0] =~ /qmail \d+ invoked by uid \d+/ or $rcvd[0] =~ /\bfrom (?:localhost\s|(?:\S+ ){1,2}\S*\b127\.0\.0\.1\b)/)
1582 0 8 if (@rcvd and $rcvd[0] =~ /\bby localhost with \w+ \(fetchmail-[\d.]+/) { }
0 8 elsif (@local) { }
1590 8 2 if (@rcvd)
1592 8 0 if defined $time
1594 0 2 if (@local)
1596 0 0 if defined $time
1598 0 2 if ($header =~ /^(?:From|X-From-Line:)\s+(.+)$/im)
1600 0 0 unless $string =~ /(?:[-+]\d{4}|\b[A-Z]{2,4}\b)/
1602 0 0 if defined $time
1604 0 2 if (@rcvd)
1606 0 0 if defined $time
1608 0 2 if ($header =~ /^Resent-Date:\s*(.+)$/im)
1610 0 0 if defined $time
1612 2 0 if ($header =~ /^Date:\s*(.+)$/im)
1614 2 0 if defined $time
1627 0 0 if ($members =~ /\b$user\b/)
1640 0 0 if &RUNNING_ON_WINDOWS()
1646 0 0 unless defined $supgs
1647 0 0 if ($( != $pgid)
1658 0 0 if ($< != $touid)
1666 0 0 if ($< != $touid)
1675 0 0 if (&RUNNING_ON_WINDOWS()) { }
1687 0 0 if ($stdinfile)
1688 0 0 if ($duperr2out)
1712 0 0 unless (eval {
1713 0 0 $@ ne '' ? :
1716 0 0 unless (defined $pid)
1721 0 0 if ($pid != 0)
1740 0 0 unless ($stdinfile)
1746 0 0 unless close STDIN
1749 0 0 if ($f != 0)
1753 0 0 unless open STDIN, "<$stdinfile"
1759 0 0 if (fileno STDIN != 0)
1775 0 0 if ($duperr2out)
1777 0 0 unless close STDERR
1780 0 0 if ($f != 2)
1784 0 0 unless open STDERR, ">&STDOUT"
1788 0 0 if (fileno STDERR != 2)
1796 0 0 $@ ne '' ? :
1818 0 0 if ($] < 5.008 or am_running_on_windows()) { }
1841 0 1275 if (ref $re)
1846 0 1275 unless defined $strip_delimiters
1854 1259 16 if ($strip_delimiters >= 1)
1856 1046 213 if ($re =~ s[^/][]) { }
73 140 elsif ($re =~ s/^(?:m|qr)([\{\(\<\[])//) { }
138 2 elsif ($re =~ s/^(?:m|qr)(\W)//) { }
2 0 elsif ($strip_delimiters != 2) { }
1866 0 138 if ($delim_end eq "\\")
1877 1257 16 if ($delim_end)
1879 1257 0 if ($re =~ s/\Q$delim_end\E([a-df-z]*)\z//) { }
1888 3 1270 if ($re =~ /\(\?\??\{/)
1895 1180 90 if ($delim_end and not $delim_end =~ tr/)]}//)
1900 3 1177 if ($dbs_stripped =~ /(?<!\\)\Q$delim_end\E/)
1905 427 840 if ($ignore_always_matching)
1906 7 420 if (my $err = is_always_matching_regexp($re))
1912 897 363 if ($mods)
1923 0 0 if (not $_[0] =~ /deprecated/i)
1930 1257 3 if ($ok and ref $compiled_re eq 'Regexp') { }
1935 3 0 $@ ne '' ? :
1944 1 426 if ($re eq '') { }
3 423 elsif ($re =~ /(?<!\\)\|\|/) { }
2 421 elsif ($re =~ /^\|/) { }
1 420 elsif ($re =~ /\|(?<!\\\|)$/) { }
1967 0 42 unless ref $re eq "Regexp"
1973 42 0 if ($re =~ s/^\(\?\^([a-z]*)://) { }
0 0 elsif ($re =~ s/^\(\?([a-z]*)-[a-z]*://) { }
1983 0 42 $mods ? :
2004 0 0 if (not defined $re or $re eq '') { }
0 0 elsif ($re =~ s/^m?\{//) { }
0 0 elsif ($re =~ s/^m?\[//) { }
0 0 elsif ($re =~ s/^m?\(//) { }
0 0 elsif ($re =~ s/^m?<//) { }
0 0 elsif ($re =~ s/^m?(\W)//) { }
2026 0 0 unless ($re =~ s/\Q$delim\E([imsx]*)$//)
2031 0 0 if ($mods)
2046 0 0 if not defined $re or $re eq ""
2048 0 0 if (eval {
2065 0 0 if defined $lang
2086 0 0 stat $file ? :
2087 0 0 if $stat_errn == 2
2090 0 0 unless unlink $file
2129 38 0 if $is_spam or $score < $rscore