Branch Coverage

lib/Mail/SpamAssassin/Util.pm
Criterion Covered Total %
branch 159 414 38.4


line true false branch
83 0 42 if (&RUNNING_ON_WINDOWS())
91 0 0 if $_[0] & 127
107 0 0 unless ($displayed_path++)
112 0 0 if (-f $fname)
113 0 0 if (-x $fname) { }
134 63 26 if $cleaned_taint_path++
135 25 1 unless am_running_in_taint_mode()
139 0 1 if (&RUNNING_ON_WINDOWS())
150 0 3 unless $dir
154 3 0 if $dir =~ /^(.+)$/
158 0 3 if (not 'File::Spec'->file_name_is_absolute($dir)) { }
0 3 elsif (not @stat = stat $dir) { }
0 3 elsif (not -d _) { }
0 3 elsif (($stat[2] & 2) != 0) { }
189 0 26 if defined $AM_TAINTED
191 26 0 if ($] >= 5.008) { }
199 0 0 unless opendir TAINT, $d
201 0 0 unless closedir TAINT
204 0 0 unless (defined $blank and $blank)
210 0 0 unless eval "1 || $blank"
212 1 25 $AM_TAINTED ? :
235 0 296 unless defined $path
236 0 296 if $path eq ''
245 296 0 if ($path =~ /$re/) { }
257 0 0 unless defined $host
258 0 0 if $host eq ''
265 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) { }
287 20492 89 if (not ref $_[0]) { }
291 4680 15812 unless defined $_[0]
298 6 83 if ($r eq 'ARRAY') { }
1 82 elsif ($r eq 'HASH') { }
82 0 elsif ($r eq 'SCALAR' or $r eq 'REF') { }
301 0 6 if wantarray
305 1 0 if ($arg == \%ENV) { }
308 0 35 unless (defined $v)
318 0 1 if wantarray
335 0 0 unless defined $v
351 0 0 if (not defined $stat) { }
0 0 elsif (WIFEXITED($stat)) { }
0 0 elsif (WIFSTOPPED($stat)) { }
359 0 0 $sig == 15 ? :
0 0 $sig == 9 ? :
0 0 $sig == 6 ? :
0 0 $sig == 2 ? :
0 0 $sig == 1 ? :
365 0 0 if (defined $errno)
366 0 0 if 0 + $errno != 0 or $errno ne '' and $errno ne '0'
379 0 0 if (!defined($errno) || $errno == 0 and WIFEXITED($exit_status))
381 0 0 if (not @success) { }
0 0 elsif (grep {$_ == $j;} @success) { }
458 0 2 if defined $LOCALTZ
478 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) { }
490 26 0 if (defined $yyyy)
491 0 26 if (length $yyyy == 2 and $yyyy < 50) { }
0 26 elsif (length $yyyy != 4) { }
501 26 0 if (s/ (\d?\d):(\d\d)(:(\d\d))? / /)
506 26 0 if (s/ ([-+]\d{4}) / /) { }
0 0 elsif (s/\b([A-Z]{2,4}(?:-DST)?)\b/ / and exists $TZ{$1}) { }
517 26 0 if (exists $MONTH{$mon})
524 1 25 if ($ss > 59)
529 1 25 if ($mm > 59)
534 1 25 if ($hh > 23)
540 9 17 if ($mmm == 4 or $mmm == 6 or $mmm == 9 or $mmm == 11) { }
8 9 elsif ($mmm == 2) { }
544 0 8 !($yyyy % 4) && ($yyyy % 100 || !($yyyy % 400)) ? :
546 5 21 if ($dd > $max_dd)
550 1 4 if ($mmm > 12)
558 0 26 if ($yyyy > 2037) { }
0 26 elsif ($yyyy < 1970) { }
571 0 26 unless (eval { do { $time = timegm($ss, $mm, $hh, $dd, $mmm - 1, $yyyy); 1 } })
572 0 0 $@ ne '' ? :
577 26 0 if ($tzoff =~ /([-+])(\d\d)(\d\d)$/)
580 13 13 if ($1 eq '-') { }
0 13 elsif ($time < $tzoff) { }
640 176 173 if $first
654 3126 566 if ($pos_mod != 0 and $overflow == 0)
660 3572 120 if ($len <= $length) { }
696 7 0 if (length($_) % 4 == 0 and m[^(?:[A-Za-z0-9+/=]{2,}={0,2})$]s)
705 0 7 if (defined $decoded_length)
717 0 0 if length($_) % 4 == 1
722 0 0 length $_ >= 84 ? :
724 0 0 if defined $decoded_length and length $out >= $decoded_length
729 0 0 if (defined $decoded_length)
770 55 26 if (defined &Mail::SpamAssassin::Util::_getpwuid_wrapper)
775 26 0 if (not &RUNNING_ON_WINDOWS()) { }
781 0 26 if (not $sts) { }
782 0 0 $@ ne '' ? :
813 0 0 unless defined $str
815 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)
822 0 0 if (defined $1)
838 0 8 if defined $hostname
851 64 8 if defined $fq_hostname
854 8 0 unless ($fq_hostname =~ /\./)
858 0 8 if @names
874 0 0 unless defined $ip1
875 0 0 unless defined $ip2
876 0 0 unless $ip1 =~ /^(\d+\.\d+\.)/
877 0 0 unless $ip2 =~ /^(\d+\.\d+\.)/
878 0 0 if ($b1 eq $b2)
891 0 0 unless defined $ip1
892 0 0 unless defined $ip2
893 0 0 unless $ip1 =~ /^(\d+\.\d+\.\d+\.)/
894 0 0 unless $ip2 =~ /^(\d+\.\d+\.\d+\.)/
895 0 0 if ($b1 eq $b2)
914 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')) { }
923 8 0 if (defined $ip_obj)
948 0 26 if utf8::is_utf8($qname)
952 0 0 $1 <= 255 ? :
0 0 length $1 == 1 ? :
991 28 306 if defined $boundary
1001 0 334 if (not $name and $ct =~ /\b(?:file)?name\*0\s*=/i)
1026 245 89 if (not $ct or $ct =~ /^text\b/ and not $ct =~ m[^text/(?:x-vcard|calendar|html)$])
1039 334 0 wantarray ? :
1052 68 73 if (/\%[0-9a-fA-F]{2}/) { }
1057 68 0 unless (/(20|7f|[0189a-fA-F][0-9a-fA-F])/i)
1067 0 0 if push @encoded, $1
1070 0 8 if (wantarray) { }
1099 6 12 if (eval 'require ' . $mod . '; 1; ')
1121 0 61 unless defined $tmpdir and $tmpdir ne ''
1124 0 61 unless opendir my $dh, $tmpdir
1125 0 61 unless closedir $dh
1137 61 0 if (sysopen $tmpfh, $reportfile, 194, 384)
1138 0 61 unless binmode $tmpfh
1144 0 0 if ($tmpfh)
1145 0 0 unless (close $tmpfh)
1152 0 0 if $errno == 17
1159 0 61 unless ($tmpfh)
1181 0 0 unless ($tmpdir)
1201 0 0 if (mkdir $reportpath, 448)
1206 0 0 if ($!{'EEXIST'})
1217 0 0 unless $tmppath
1239 63 2010 if $uri =~ /^mailto:/i or $uri =~ /^[^:]*\@/
1265 8 2002 if ($nuri =~ /%[0-9a-fA-F]{2}/)
1271 378 1632 unless ($nuri =~ /^[-_a-z0-9]+:/i)
1272 2 376 if ($nuri =~ /^ftp\./) { }
1289 393 1617 if ($nuri ne $uri)
1294 1990 20 if ($nuri =~ m[^(https?://)([^/]+?)((?::\d*)?\/.*)?$]i)
1311 10 1980 if ($host =~ s/(?: \xE3\x80\x82 | \xEF\xBC\x8E | \xEF\xBD\xA1 | \xEF\xB9\x92 | \xE2\x80\xA4 )/./gsx)
1319 0 1990 if ($host =~ tr/\000- \200-\377//d)
1331 4 13812 if ("$proto$host$rest" =~ /$re/)
1332 0 4 unless defined $1
1340 1986 4 unless ($found_redirector_match)
1343 6 1980 if ($rest =~ m[(https?:/{0,2}.+)$]i)
1356 9 1981 if ($host =~ s/^[^\@]+\@//gs)
1364 1 1989 if ($host =~ s/[^0-9A-Za-z]+$//)
1375 67 1923 if ($host =~ /^ ((?:0x[0-9a-f]+|\d+)\.) ((?:0x[0-9a-f]+|\d+)\.) ((?:0x[0-9a-f]+|\d+)\.) (0x[0-9a-f]+|\d+) $/xi) { }
6 1917 elsif ($host =~ /^0x[0-9a-f]+$/i) { }
20 1897 elsif ($host =~ /^[0-9]+$/) { }
1423 10 0 if defined $time and $time
1438 8 2 if (@rcvd)
1439 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)/)
1444 0 8 if (@rcvd and $rcvd[0] =~ /\bby localhost with \w+ \(fetchmail-[\d.]+/) { }
0 8 elsif (@local) { }
1452 8 2 if (@rcvd)
1454 8 0 if defined $time
1456 0 2 if (@local)
1458 0 0 if defined $time
1460 0 2 if ($header =~ /^(?:From|X-From-Line:)\s+(.+)$/im)
1462 0 0 unless $string =~ /(?:[-+]\d{4}|\b[A-Z]{2,4}\b)/
1464 0 0 if defined $time
1466 0 2 if (@rcvd)
1468 0 0 if defined $time
1470 0 2 if ($header =~ /^Resent-Date:\s*(.+)$/im)
1472 0 0 if defined $time
1474 2 0 if ($header =~ /^Date:\s*(.+)$/im)
1476 2 0 if defined $time
1489 0 0 if ($members =~ /\b$user\b/)
1502 0 0 if &RUNNING_ON_WINDOWS()
1508 0 0 unless defined $supgs
1509 0 0 if ($( != $pgid)
1520 0 0 if ($< != $touid)
1528 0 0 if ($< != $touid)
1537 0 0 if (&RUNNING_ON_WINDOWS()) { }
1549 0 0 if ($stdinfile)
1550 0 0 if ($duperr2out)
1574 0 0 unless (eval { do { $pid = open($fh, '-|'); 1 } })
1575 0 0 $@ ne '' ? :
1578 0 0 unless (defined $pid)
1583 0 0 if ($pid != 0)
1602 0 0 unless ($stdinfile)
1608 0 0 unless close STDIN
1611 0 0 if ($f != 0)
1615 0 0 unless open STDIN, "<$stdinfile"
1621 0 0 if (fileno STDIN != 0)
1637 0 0 if ($duperr2out)
1639 0 0 unless close STDERR
1642 0 0 if ($f != 2)
1646 0 0 unless open STDERR, '>&STDOUT'
1650 0 0 if (fileno STDERR != 2)
1658 0 0 $@ ne '' ? :
1680 0 0 if ($] < 5.008 or am_running_on_windows()) { }
1701 0 42 if (not defined $re or $re eq '') { }
0 42 elsif ($re =~ s/^m\{//) { }
0 42 elsif ($re =~ s/^m\(//) { }
0 42 elsif ($re =~ s/^m<//) { }
0 42 elsif ($re =~ s/^m(\W)//) { }
1720 0 42 unless $re =~ s/\Q$delim\E([imsx]*)$//
1723 20 22 if ($mods)
1748 0 0 if defined $lang
1769 0 0 stat $file ? :
1770 0 0 if $stat_errn == 2
1773 0 0 unless unlink $file
1812 38 0 if $is_spam or $score < $rscore