Branch Coverage

lib/Mail/SpamAssassin/Util.pm
Criterion Covered Total %
branch 228 530 43.0


line true false branch
84 0 43 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 25 if $cleaned_taint_path++
136 0 25 unless am_running_in_taint_mode()
140 0 25 if (&RUNNING_ON_WINDOWS())
151 0 93 unless $dir
155 93 0 if $dir =~ /^(.+)$/
159 3 90 if (not 'File::Spec'->file_name_is_absolute($dir)) { }
0 90 elsif (not @stat = stat $dir) { }
0 90 elsif (not -d _) { }
0 90 elsif (($stat[2] & 2) != 0) { }
190 149 25 if defined $AM_TAINTED
192 25 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 25 0 $AM_TAINTED ? :
236 0 311 unless defined $path
237 0 311 if $path eq ''
246 311 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 13071 97 if (not ref $_[0]) { }
292 0 13071 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 1070 unless defined $v
351 0 588 unless defined $host
357 0 588 if length $host > 253
362 47 541 unless $cnt > 1
365 11 1328 if length $label < 1
366 0 1328 if length $label > 63
369 22 1306 unless $label =~ /^[a-z0-9_](?:[a-z0-9_-]*[a-z0-9_])?$/
371 1000 306 if ($cnt == 2 or $cnt == 1)
372 16 984 if index($label, '_') != -1
390 0 0 if (not defined $stat) { }
0 0 elsif (WIFEXITED($stat)) { }
0 0 elsif (WIFSTOPPED($stat)) { }
398 0 0 $sig == 15 ? :
0 0 $sig == 9 ? :
0 0 $sig == 6 ? :
0 0 $sig == 2 ? :
0 0 $sig == 1 ? :
404 0 0 if (defined $errno)
405 0 0 if 0 + $errno != 0 or $errno ne '' and $errno ne '0'
418 0 0 if (!defined($errno) || $errno == 0 and WIFEXITED($exit_status))
420 0 0 if (not @success) { }
0 0 elsif (grep {$_ == $j;} @success) { }
497 0 2 if defined $LOCALTZ
517 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) { }
529 26 0 if (defined $yyyy)
530 0 26 if (length $yyyy == 2 and $yyyy < 50) { }
0 26 elsif (length $yyyy != 4) { }
540 26 0 if (s/ (\d?\d):(\d\d)(:(\d\d))? / /)
545 26 0 if (s/ ([-+]\d{4}) / /) { }
0 0 elsif (s/\b([A-Z]{2,4}(?:-DST)?)\b/ / and exists $TZ{$1}) { }
556 26 0 if (exists $MONTH{$mon})
563 1 25 if ($ss > 59)
568 1 25 if ($mm > 59)
573 1 25 if ($hh > 23)
579 9 17 if ($mmm == 4 or $mmm == 6 or $mmm == 9 or $mmm == 11) { }
8 9 elsif ($mmm == 2) { }
583 0 8 !($yyyy % 4) && ($yyyy % 100 || !($yyyy % 400)) ? :
585 5 21 if ($dd > $max_dd)
589 1 4 if ($mmm > 12)
597 0 26 if ($yyyy > 2037) { }
0 26 elsif ($yyyy < 1970) { }
610 0 26 unless (eval { do { $time = timegm($ss, $mm, $hh, $dd, $mmm - 1, $yyyy); 1 } })
611 0 0 $@ ne '' ? :
616 26 0 if ($tzoff =~ /([-+])(\d\d)(\d\d)$/)
619 13 13 if ($1 eq '-') { }
0 13 elsif ($time < $tzoff) { }
679 192 173 if $first
693 3254 584 if ($pos_mod != 0 and $overflow == 0)
699 3716 122 if ($len <= $length) { }
735 7 0 if (length($_) % 4 == 0 and m[^(?:[A-Za-z0-9+/=]{2,}={0,2})$]s)
744 0 7 if (defined $decoded_length)
756 0 0 if length($_) % 4 == 1
761 0 0 length $_ >= 84 ? :
763 0 0 if defined $decoded_length and length $out >= $decoded_length
768 0 0 if (defined $decoded_length)
809 70 25 if (defined &Mail::SpamAssassin::Util::_getpwuid_wrapper)
814 25 0 if (not &RUNNING_ON_WINDOWS()) { }
820 0 25 if (not $sts) { }
821 0 0 $@ ne '' ? :
852 0 0 unless defined $str
854 0 0 if ($str =~ /\b( (?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)\. (?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)\. (?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d)\. (?:1\d\d|2[0-4]\d|25[0-5]|[1-9]\d|\d) )\b/xi)
861 0 0 if (defined $1)
877 0 9 if defined $hostname
890 68 9 if defined $fq_hostname
893 9 0 unless ($fq_hostname =~ /\./)
897 0 9 if @names
913 0 0 unless defined $ip1
914 0 0 unless defined $ip2
915 0 0 unless $ip1 =~ /^(\d+\.\d+\.)/
916 0 0 unless $ip2 =~ /^(\d+\.\d+\.)/
917 0 0 if ($b1 eq $b2)
930 0 0 unless defined $ip1
931 0 0 unless defined $ip2
932 0 0 unless $ip1 =~ /^(\d+\.\d+\.\d+\.)/
933 0 0 unless $ip2 =~ /^(\d+\.\d+\.\d+\.)/
934 0 0 if ($b1 eq $b2)
953 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')) { }
962 8 0 if (defined $ip_obj)
987 0 42 if utf8::is_utf8($qname)
991 0 0 $1 <= 255 ? :
0 0 length $1 == 1 ? :
1030 28 330 if defined $boundary
1040 0 358 if (not $name and $ct =~ /\b(?:file)?name\*0\s*=/i)
1065 269 89 if (not $ct or $ct =~ /^text\b/ and not $ct =~ m[^text/(?:x-vcard|calendar|html)$])
1078 358 0 wantarray ? :
1091 67 71 if (/\%[0-9a-fA-F]{2}/) { }
1096 67 0 unless (/(20|7f|[0189a-fA-F][0-9a-fA-F])/i)
1106 0 0 if push @encoded, $1
1109 0 7 if (wantarray) { }
1138 0 30 unless $mod =~ /^[\w:]+$/
1139 10 20 if (eval 'require ' . $mod . '; 1;')
1165 0 0 unless defined $file and $file ne ''
1167 0 0 if ($args->{'create_exclusive'})
1168 0 0 if (sysopen my $fh, $file, 192)
1172 0 0 if $! == 17
1177 0 0 unless (utime undef, undef, $file)
1198 0 65 am_running_on_windows() ? :
1201 0 65 unless defined $tmpdir and $tmpdir ne ''
1204 0 65 unless opendir my $dh, $tmpdir
1205 0 65 unless closedir $dh
1217 65 0 if (sysopen $tmpfh, $reportfile, 194, 384)
1218 0 65 unless binmode $tmpfh
1224 0 0 if ($tmpfh)
1225 0 0 unless (close $tmpfh)
1232 0 0 if $errno == 17
1239 0 65 unless ($tmpfh)
1261 0 0 unless ($tmpdir)
1281 0 0 if (mkdir $reportpath, 448)
1286 0 0 if ($!{'EEXIST'})
1297 0 0 unless $tmppath
1333 36 413 if ($nuri =~ /^mailto:/i or $nuri =~ /^[^:]*\@/)
1336 0 36 if ($nuri =~ /^([^\@]+\@[^?]+)\?/)
1339 0 36 if ($nuri =~ /^([^\@]+\@[^?&]+)\&/)
1343 8 28 if ($nuri =~ tr/%02// and $nuri =~ /^(?:mailto:)?(?:\%20)*([^\@]+\@[^?&%]+)/)
1348 0 36 if ($nuri =~ /^[^?&]*<([^\@>]+\@[^>]+)>/)
1366 7 406 if ($nuri =~ /%[0-9a-fA-F]{2}/)
1372 77 336 unless ($nuri =~ /^[-_a-z0-9]+:/i)
1373 1 76 if ($nuri =~ /^ftp\./) { }
1393 91 322 if ($nuri ne $uri)
1398 400 13 if ($nuri =~ m[^(https?://)([^\@/?#]*\@)?([^/?#:]+)((?::(\d*))?.*)$]i)
1400 10 390 defined $2 ? :
1401 29 371 defined $5 ? :
1404 382 18 if ($port eq '') { }
1405 376 6 $proto eq 'http://' ? :
1409 18 0 if ($proto eq 'http://') { }
0 0 elsif ($rest_noport =~ s/^:443\b//) { }
1410 14 4 if ($rest_noport =~ s/^:80\b//)
1429 5 395 if ($host =~ s/(?: \xE3\x80\x82 | \xEF\xBC\x8E | \xEF\xBD\xA1 | \xEF\xB9\x92 | \xE2\x80\xA4 )/./gsx)
1433 0 5 if $rest_noport
1442 0 400 if ($host =~ tr/\000- //d)
1454 4 1898 if ("$proto$host$rest" =~ /$re/)
1455 0 4 unless defined $1 and index($1, '.') != -1
1463 396 4 unless ($found_redirector_match)
1466 6 390 if ($rest =~ m[(https?:/{0,2}[^&#]+)]i and index($1, '.') != -1)
1479 0 400 if ($host =~ s/^[^\@]+\@//gs)
1487 1 399 if ($host =~ s/[^0-9A-Za-z]+$//)
1498 35 365 if ($host =~ /^ ((?:0x[0-9a-f]+|\d+)\.) ((?:0x[0-9a-f]+|\d+)\.) ((?:0x[0-9a-f]+|\d+)\.) (0x[0-9a-f]+|\d+) $/xi) { }
6 359 elsif ($host =~ /^0x[0-9a-f]+$/i) { }
19 340 elsif ($host =~ /^[0-9]+$/) { }
12 331 elsif ($proto eq 'http://' and $auth eq '' and $host ne 'localhost' and $port eq '80' and $host =~ /^(?:www\.)?([^.]+)$/) { }
1554 10 0 if defined $time and $time
1569 8 2 if (@rcvd)
1570 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)/)
1575 0 8 if (@rcvd and $rcvd[0] =~ /\bby localhost with \w+ \(fetchmail-[\d.]+/) { }
0 8 elsif (@local) { }
1583 8 2 if (@rcvd)
1585 8 0 if defined $time
1587 0 2 if (@local)
1589 0 0 if defined $time
1591 0 2 if ($header =~ /^(?:From|X-From-Line:)\s+(.+)$/im)
1593 0 0 unless $string =~ /(?:[-+]\d{4}|\b[A-Z]{2,4}\b)/
1595 0 0 if defined $time
1597 0 2 if (@rcvd)
1599 0 0 if defined $time
1601 0 2 if ($header =~ /^Resent-Date:\s*(.+)$/im)
1603 0 0 if defined $time
1605 2 0 if ($header =~ /^Date:\s*(.+)$/im)
1607 2 0 if defined $time
1620 0 0 if ($members =~ /\b$user\b/)
1633 0 0 if &RUNNING_ON_WINDOWS()
1639 0 0 unless defined $supgs
1640 0 0 if ($( != $pgid)
1651 0 0 if ($< != $touid)
1659 0 0 if ($< != $touid)
1668 0 0 if (&RUNNING_ON_WINDOWS()) { }
1680 0 0 if ($stdinfile)
1681 0 0 if ($duperr2out)
1705 0 0 unless (eval { do { $pid = open($fh, '-|'); 1 } })
1706 0 0 $@ ne '' ? :
1709 0 0 unless (defined $pid)
1714 0 0 if ($pid != 0)
1733 0 0 unless ($stdinfile)
1739 0 0 unless close STDIN
1742 0 0 if ($f != 0)
1746 0 0 unless open STDIN, "<$stdinfile"
1752 0 0 if (fileno STDIN != 0)
1768 0 0 if ($duperr2out)
1770 0 0 unless close STDERR
1773 0 0 if ($f != 2)
1777 0 0 unless open STDERR, '>&STDOUT'
1781 0 0 if (fileno STDERR != 2)
1789 0 0 $@ ne '' ? :
1811 0 0 if ($] < 5.008 or am_running_on_windows()) { }
1834 0 1256 if (ref $re)
1839 0 1256 unless defined $strip_delimiters
1847 1240 16 if ($strip_delimiters >= 1)
1849 1030 210 if ($re =~ s[^/][]) { }
72 138 elsif ($re =~ s/^(?:m|qr)([\{\(\<\[])//) { }
136 2 elsif ($re =~ s/^(?:m|qr)(\W)//) { }
2 0 elsif ($strip_delimiters != 2) { }
1859 0 136 if ($delim_end eq '\\')
1870 1238 16 if ($delim_end)
1872 1238 0 if ($re =~ s/\Q$delim_end\E([a-df-z]*)\z//) { }
1881 3 1251 if ($re =~ /\(\?\??\{/)
1888 1162 89 if ($delim_end and not $delim_end =~ tr/)]}//)
1893 3 1159 if ($dbs_stripped =~ /(?<!\\)\Q$delim_end\E/)
1898 427 821 if ($ignore_always_matching)
1899 7 420 if (my $err = is_always_matching_regexp($re))
1905 883 358 if ($mods)
1916 0 0 if (not $_[0] =~ /deprecated/i)
1923 1238 3 if ($ok and ref $compiled_re eq 'Regexp') { }
1928 3 0 $@ ne '' ? :
1937 1 426 if ($re eq '') { }
3 423 elsif ($re =~ /(?<!\\)\|\|/) { }
2 421 elsif ($re =~ /^\|/) { }
1 420 elsif ($re =~ /\|(?<!\\\|)$/) { }
1960 0 42 unless ref $re eq 'Regexp'
1966 42 0 if ($re =~ s/^\(\?\^([a-z]*)://) { }
0 0 elsif ($re =~ s/^\(\?([a-z]*)-[a-z]*://) { }
1976 0 42 $mods ? :
1997 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)//) { }
2019 0 0 unless ($re =~ s/\Q$delim\E([imsx]*)$//)
2024 0 0 if ($mods)
2039 0 0 if not defined $re or $re eq ''
2041 0 0 if (eval { do { $compiled_re = qr/$re/; 1 } } and ref $compiled_re eq 'Regexp') { }
2058 0 0 if defined $lang
2079 0 0 stat $file ? :
2080 0 0 if $stat_errn == 2
2083 0 0 unless unlink $file
2122 38 0 if $is_spam or $score < $rscore