Branch Coverage

blib/lib/Mail/SpamAssassin/Message.pm
Criterion Covered Total %
branch 181 256 70.7


line true false branch
51 0 40 unless (eval { do { require Digest::SHA; 'Digest::SHA'->import('sha1', 'sha1_hex'); 1 } })
104 149 0 defined $opts->{'message'} ? :
111 4 145 defined $opts->{'subparse'} ? :
126 49 100 if ($self->{'suppl_attrib'})
129 0 49 if (defined $self->{'suppl_attrib'}{'body_size'})
136 0 49 if (ref $self->{'suppl_attrib'}{'mimepart_digests'})
157 63 86 if (ref $message eq 'ARRAY') { }
18 68 elsif (ref $message eq 'GLOB' or ref($message) =~ /^IO::/) { }
0 68 elsif (ref $message eq 'SCALAR') { }
0 68 elsif (ref $message) { }
68 0 elsif (defined $message) { }
161 18 0 if (defined fileno $message)
169 0 18 unless defined $nread
172 0 18 if ($raw_str eq '') { }
0 18 elsif (length $raw_str > 131072) { }
195 0 149 unless (@message)
207 119 30 if (Mail::SpamAssassin::Util::am_running_in_taint_mode() and grep {not &Scalar::Util::tainted($_);} @message)
215 0 119 if (grep {not &Scalar::Util::tainted($_);} @message)
221 17 132 if ($message[0] =~ /^From\s+(?!:)/) { }
0 132 elsif ($message[0] =~ /^([\s\d]\d-[a-zA-Z]{3}-\d{4}\s\d{2}:\d{2}:\d{2}.*),(\d+);([\da-f]{12})-(\w{8})\r?$/) { }
232 0 0 if (/([\s\d]\d)-([a-zA-Z]{3})-(\d{4})\s(\d{2}):(\d{2}):(\d{2})/)
242 0 0 if (/^From:[^<]*<([^>]+)>/) { }
0 0 elsif (/^From:\s*([^<> ]+)/) { }
257 0 149 if (@message and $message[0] =~ /\015\012/ || $message[-1] =~ /\015\012/)
271 1 1165 $eof ? :
273 200 966 if ($current =~ /^[ \t]/) { }
280 0 200 unless defined $header
286 817 149 if (defined $header)
290 811 6 if (defined $value)
292 0 811 if $squash_crlf
295 0 811 if (length $key > 256)
299 0 811 if (length $value > 8192)
307 144 822 if ($current =~ /^\r?$/) { }
4 818 elsif ($current =~ /^--/) { }
308 1 143 if ($eof) { }
323 7 811 unless ($current =~ /^[\041-\071\073-\176]+[ \t]*:/)
328 6 1 if (++$hdr_errors <= 3) { }
349 149 0 unless (defined $self->{'pristine_body_length'})
361 0 3682 if $squash_crlf
364 414 3268 if ($message[$cnt] =~ /^\s*$/)
366 346 68 unless (defined $start)
369 379 35 unless $cnt == 0
375 346 2957 if (defined $start)
378 0 346 if ($num > $max_blank_lines)
396 14 1 if ($self->{'type'} =~ m[^multipart/]i and $#message > 0 and $message[0] =~ /\S/)
398 4 10 unless (defined $boundary and $message[0] =~ /^--\Q$boundary\E/)
420 101 48 if ($parsenow)
444 36 219 if exists $self->{'parse_queue'}
478 32 44 if not defined $hdr or $hdr eq ''
482 34 10 if (not @ret) { }
0 10 elsif (wantarray) { }
548 14 102 if $self->{'already_extracted_metadata'}
562 0 2942 unless ($self->{'metadata'})
577 0 408 unless ($self->{'metadata'})
590 0 0 unless ($self->{'metadata'})
603 0 16 unless ($self->{'metadata'})
610 0 64 unless defined $val
613 16 0 wantarray ? :
628 124 0 if (defined $self->{'metadata'})
666 20 118 if (ref $part->{'raw'} eq 'GLOB')
667 0 20 unless close $part->{'raw'}
671 4 134 if (defined $part->{'metadata'})
688 23 115 if (exists $part->{'body_parts'})
695 92 0 if ($self->{'tmpfiles'})
697 0 20 unless unlink $fn
710 36 92 if ($self->{'tmpfiles'})
712 0 0 unless unlink $fn
764 0 137 unless exists $self->{'parse_queue'}
775 20 165 if ($msg->{'type'} =~ m[^multipart/]i and defined $boundary and $subparse > 0) { }
783 4 161 if ($msg->{'type'} =~ m[^message/(?!partial\z)]i and $subparse > 0)
799 4 0 if ($msg->{'type'} =~ m[^message/(?:rfc822|global)\z]i and defined $msg->{'decoded'} and $msg->{'decoded'} ne '')
827 0 4 if (ref $msg->{'raw'} eq 'GLOB')
829 0 0 unless close $msg->{'raw'}
865 20 0 defined $boundary ? :
872 20 0 if (defined $boundary)
878 19 101 if (substr($body->[$line], 0, 2) eq '--' and $body->[$line] =~ /^--\Q$boundary\E\s*$/)
886 5 14 if ($line + 1 < $tmp_line and not $$body[$line + 1] =~ /^[\041-\071\073-\176]+:/)
895 19 1 if ($line < $tmp_line)
917 44 2216 if (--$line_count == 0 or $found_end_boundary)
926 0 44 if (not $found_end_boundary) { }
44 0 elsif ($part_array) { }
944 24 20 if $part_array->[-1] eq ''
955 44 0 defined $p_boundary ? :
966 44 0 if (defined $boundary)
968 20 24 if ($line =~ /^--\Q$boundary\E--\s*$/) { }
0 24 elsif ($line_count and not $$body[-$line_count] =~ /^[\041-\071\073-\176]+:/) { }
982 0 24 if (++$partcnt == 1000)
997 132 2084 unless ($in_body)
1000 87 45 if (/^[\041-\071\073-\176]+[ \t]*:/) { }
1 44 elsif (/^[ \t]/ and $header) { }
1001 49 38 if ($header)
1014 38 6 if ($header)
1022 43 1 if (/^\r?$/) { }
1047 8 12 if ($line_count)
1049 2 13 if ($$body[-$line_count] =~ /[^\s.]/)
1076 165 0 !($ct[0] =~ m[^multipart/]i) || defined $boundary ? :
1081 1 164 if ($disp =~ /name=\s*"?([^";]+)"?/i) { }
2 162 elsif ($ct[3]) { }
1087 3 162 if ($msg->{'name'})
1097 20 145 unless ($msg->{'type'} =~ m[^(?:text/(?:plain|html)$|message\b)])
1101 0 20 unless (eval { do { ($filepath, $fh) = Mail::SpamAssassin::Util::secure_tmpfile(); 1 } })
1102 0 0 $@ ne '' ? :
1105 20 0 if ($fh)
1111 0 20 unless $fh->print(@{$body;})
1112 0 20 unless $fh->flush
1118 145 20 if (not defined $msg->{'raw'})
1129 0 0 unless (exists $self->{'mimepart_digests'})
1147 247 140 if (exists $self->{$key})
1155 0 140 unless @parts
1161 8 132 $method_name eq 'invisible_rendered' ? :
1169 133 8 if $text ne ''
1173 141 0 if (defined $rnd)
1175 8 133 if ($scansize and length $rnd > $scansize)
1179 2 6 if ($idx >= 0 and $idx - $scansize <= 1024) { }
1185 1 5 if ($idx >= 0 and $idx - $scansize <= 1024) { }
1201 7 134 if ($html_needs_setting and $type eq 'text/html')
1241 2 108 if (defined $self->{'text_decoded'})
1248 0 108 unless @parts
1254 0 108 if $parts[$pt]{'type'} eq 'text/calendar'
1260 8 100 if ($scansize and $rawlen > $scansize)
1264 2 6 if ($idx >= 0 and $idx - $scansize <= 1024) { }
1270 1 5 if ($idx >= 0 and $idx - $scansize <= 1024) { }
1276 0 5 if ($idx >= 0 and $idx - $scansize <= 1024) { }
1318 103 5 if $text_l <= 2048
1323 0 1 if ($j < 0 or $j - $ofs + 1 > 4096)
1325 0 0 if ($j < 0 or $j - $ofs + 1 > 4096)
1327 0 0 if ($j < 0 or $j - $ofs + 1 > 4096)
1334 5 0 if $ofs < $text_l