Branch Coverage

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


line true false branch
51 0 41 unless (eval {
104 150 0 defined $opts->{'message'} ? :
111 4 146 defined $opts->{'subparse'} ? :
126 49 101 if ($self->{'suppl_attrib'})
129 0 49 if (defined $self->{'suppl_attrib'}{'body_size'})
137 0 49 if (ref $self->{'suppl_attrib'}{'mimepart_digests'})
159 63 87 if (ref $message eq 'ARRAY') { }
18 69 elsif (ref $message eq 'GLOB' or ref($message) =~ /^IO::/) { }
0 69 elsif (ref $message eq 'SCALAR') { }
0 69 elsif (ref $message) { }
69 0 elsif (defined $message) { }
163 18 0 if (defined fileno $message)
171 0 18 unless defined $nread
174 0 18 if ($raw_str eq '') { }
0 18 elsif (length $raw_str > 131072) { }
197 0 150 unless (@message)
209 120 30 if (Mail::SpamAssassin::Util::am_running_in_taint_mode() and grep {not &Scalar::Util::tainted($_);} @message)
217 0 120 if (grep {not &Scalar::Util::tainted($_);} @message)
223 17 133 if ($message[0] =~ /^From\s+(?!:)/) { }
0 133 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?$/) { }
234 0 0 if (/([\s\d]\d)-([a-zA-Z]{3})-(\d{4})\s(\d{2}):(\d{2}):(\d{2})/)
244 0 0 if (/^From:[^<]*<([^>]+)>/) { }
0 0 elsif (/^From:\s*([^<> ]+)/) { }
259 0 150 if (@message and $message[0] =~ /\015\012/ || $message[-1] =~ /\015\012/)
273 1 1174 $eof ? :
275 201 974 if ($current =~ /^[ \t]/) { }
282 0 201 unless defined $header
288 824 150 if (defined $header)
292 818 6 if (defined $value)
294 0 818 if $squash_crlf
297 0 818 if (length $key > 256)
301 0 818 if (length $value > 8192)
309 145 829 if ($current =~ /^\r?$/) { }
4 825 elsif ($current =~ /^--/) { }
310 1 144 if ($eof) { }
325 7 818 unless ($current =~ /^[\041-\071\073-\176]+[ \t]*:/)
330 6 1 if (++$hdr_errors <= 3) { }
351 150 0 unless (defined $self->{'pristine_body_length'})
363 0 3787 if $squash_crlf
366 418 3369 if ($message[$cnt] =~ /^\s*$/)
368 350 68 unless (defined $start)
371 383 35 unless $cnt == 0
377 350 3054 if (defined $start)
380 0 350 if ($num > $max_blank_lines)
398 15 1 if ($self->{'type'} =~ m[^multipart/]i and $#message > 0 and $message[0] =~ /\S/)
400 4 11 unless (defined $boundary and $message[0] =~ /^--\Q$boundary\E/)
422 101 49 if ($parsenow)
446 37 219 if exists $self->{'parse_queue'}
480 32 44 if not defined $hdr or $hdr eq ""
484 34 10 if (not @ret) { }
0 10 elsif (wantarray) { }
550 14 102 if $self->{'already_extracted_metadata'}
564 0 2754 unless ($self->{'metadata'})
579 0 408 unless ($self->{'metadata'})
592 0 0 unless ($self->{'metadata'})
605 0 16 unless ($self->{'metadata'})
612 0 64 unless defined $val
615 16 0 wantarray ? :
630 124 0 if (defined $self->{'metadata'})
668 20 118 if (ref $part->{'raw'} eq "GLOB")
669 0 20 unless close $part->{'raw'}
673 4 134 if (defined $part->{'metadata'})
690 23 115 if (exists $part->{'body_parts'})
697 92 0 if ($self->{'tmpfiles'})
699 0 20 unless unlink $fn
712 36 92 if ($self->{'tmpfiles'})
714 0 0 unless unlink $fn
766 0 138 unless exists $self->{'parse_queue'}
777 21 167 if ($msg->{'type'} =~ m[^multipart/]i and defined $boundary and $subparse > 0) { }
785 4 163 if ($msg->{'type'} =~ m[^message/(?!partial\z)]i and $subparse > 0)
801 4 0 if ($msg->{'type'} =~ m[^message/(?:rfc822|global)\z]i and defined $msg->{'decoded'} and $msg->{'decoded'} ne "")
829 0 4 if (ref $msg->{'raw'} eq "GLOB")
831 0 0 unless close $msg->{'raw'}
867 21 0 defined $boundary ? :
874 21 0 if (defined $boundary)
880 20 101 if (substr($body->[$line], 0, 2) eq "--" and $body->[$line] =~ /^--\Q$boundary\E\s*$/)
888 5 15 if ($line + 1 < $tmp_line and not $$body[$line + 1] =~ /^[\041-\071\073-\176]+:/)
897 20 1 if ($line < $tmp_line)
919 46 2318 if (--$line_count == 0 or $found_end_boundary)
928 0 46 if (not $found_end_boundary) { }
46 0 elsif ($part_array) { }
946 26 20 if $part_array->[-1] eq ""
957 46 0 defined $p_boundary ? :
968 46 0 if (defined $boundary)
970 21 25 if ($line =~ /^--\Q$boundary\E--\s*$/) { }
0 25 elsif ($line_count and not $$body[-$line_count] =~ /^[\041-\071\073-\176]+:/) { }
984 0 25 if (++$partcnt == 1000)
999 138 2180 unless ($in_body)
1002 91 47 if (/^[\041-\071\073-\176]+[ \t]*:/) { }
1 46 elsif (/^[ \t]/ and $header) { }
1003 51 40 if ($header)
1016 40 6 if ($header)
1024 45 1 if (/^\r?$/) { }
1049 8 13 if ($line_count)
1051 2 13 if ($$body[-$line_count] =~ /[^\s.]/)
1078 167 0 !($ct[0] =~ m[^multipart/]i) || defined $boundary ? :
1083 1 166 if ($disp =~ /name=\s*"?([^";]+)"?/i) { }
2 164 elsif ($ct[3]) { }
1089 3 164 if ($msg->{'name'})
1099 20 147 unless ($msg->{'type'} =~ m[^(?:text/(?:plain|html)$|message\b)])
1103 0 20 unless (eval {
1104 0 0 $@ ne '' ? :
1107 20 0 if ($fh)
1113 0 20 unless $fh->print(@{$body;})
1114 0 20 unless $fh->flush
1120 147 20 if (not defined $msg->{'raw'})
1131 0 0 unless (exists $self->{'mimepart_digests'})
1149 247 141 if (exists $self->{$key})
1157 0 141 unless @parts
1163 8 133 $method_name eq 'invisible_rendered' ? :
1171 135 8 if $text ne ""
1175 143 0 if (defined $rnd)
1177 8 135 if ($scansize and length $rnd > $scansize)
1181 2 6 if ($idx >= 0 and $idx - $scansize <= 1024) { }
1187 1 5 if ($idx >= 0 and $idx - $scansize <= 1024) { }
1203 8 135 if ($html_needs_setting and $type eq "text/html")
1243 2 108 if (defined $self->{'text_decoded'})
1250 0 108 unless @parts
1256 0 108 if $parts[$pt]{'type'} eq "text/calendar"
1262 8 100 if ($scansize and $rawlen > $scansize)
1266 2 6 if ($idx >= 0 and $idx - $scansize <= 1024) { }
1272 1 5 if ($idx >= 0 and $idx - $scansize <= 1024) { }
1278 0 5 if ($idx >= 0 and $idx - $scansize <= 1024) { }
1320 103 5 if $text_l <= 2048
1325 0 1 if ($j < 0 or $j - $ofs + 1 > 4096)
1327 0 0 if ($j < 0 or $j - $ofs + 1 > 4096)
1329 0 0 if ($j < 0 or $j - $ofs + 1 > 4096)
1336 5 0 if $ofs < $text_l