Branch Coverage

blib/lib/Mail/SpamAssassin/Message.pm
Criterion Covered Total %
branch 163 232 70.2


line true false branch
51 0 40 unless (eval { do { require Digest::SHA; 'Digest::SHA'->import('sha1', 'sha1_hex'); 1 } })
104 137 0 defined $opts->{'message'} ? :
111 4 133 defined $opts->{'subparse'} ? :
123 49 88 if ($self->{'suppl_attrib'})
126 0 49 if (defined $self->{'suppl_attrib'}{'body_size'})
133 0 49 if (ref $self->{'suppl_attrib'}{'mimepart_digests'})
154 63 74 if (ref $message eq 'ARRAY') { }
18 56 elsif (ref $message eq 'GLOB' or ref($message) =~ /^IO::/) { }
0 56 elsif (ref $message eq 'SCALAR') { }
0 56 elsif (ref $message) { }
56 0 elsif (defined $message) { }
158 18 0 if (defined fileno $message)
166 0 18 unless defined $nread
169 0 18 if ($raw_str eq '') { }
0 18 elsif (length $raw_str > 131072) { }
193 0 137 if (not @message) { }
17 120 elsif ($message[0] =~ /^From\s+(?!:)/) { }
0 120 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?$/) { }
209 0 0 if (/([\s\d]\d)-([a-zA-Z]{3})-(\d{4})\s(\d{2}):(\d{2}):(\d{2})/)
219 0 0 if (/^From:[^<]*<([^>]+)>/) { }
0 0 elsif (/^From:\s*([^<> ]+)/) { }
234 0 137 if (@message and $message[0] =~ /\015\012/ || $message[-1] =~ /\015\012/)
248 1 1055 $eof ? :
250 200 856 if ($current =~ /^[ \t]/) { }
257 0 200 unless defined $header
263 719 137 if (defined $header)
267 713 6 if (defined $value)
269 0 713 if $squash_crlf
272 0 713 if (length $key > 256)
276 0 713 if (length $value > 8192)
284 132 724 if ($current =~ /^\r?$/) { }
4 720 elsif ($current =~ /^--/) { }
285 1 131 if ($eof) { }
300 7 713 unless ($current =~ /^[\041-\071\073-\176]+[ \t]*:/)
305 6 1 if (++$hdr_errors <= 3) { }
326 137 0 unless (defined $self->{'pristine_body_length'})
335 0 4180 if $squash_crlf
338 414 3766 if ($message[$cnt] =~ /^\s*$/)
340 346 68 unless (defined $start)
343 379 35 unless $cnt == 0
349 346 3455 if (defined $start)
352 0 346 if ($num > $max_blank_lines)
370 14 1 if ($self->{'type'} =~ m[^multipart/]i and $#message > 0 and $message[0] =~ /\S/)
372 4 10 unless (defined $boundary and $message[0] =~ /^--\Q$boundary\E/)
394 101 36 if ($parsenow)
418 24 207 if exists $self->{'parse_queue'}
452 43 12 if not defined $hdr or $hdr eq ''
456 2 10 if (not @ret) { }
0 10 elsif (wantarray) { }
522 14 102 if $self->{'already_extracted_metadata'}
536 0 2859 unless ($self->{'metadata'})
551 0 408 unless ($self->{'metadata'})
564 0 0 unless ($self->{'metadata'})
577 0 16 unless ($self->{'metadata'})
584 0 64 unless defined $val
587 16 0 wantarray ? :
602 112 0 if (defined $self->{'metadata'})
637 20 106 if (ref $part->{'raw'} eq 'GLOB')
638 0 20 unless close $part->{'raw'}
642 4 122 if (defined $part->{'metadata'})
659 23 103 if (exists $part->{'body_parts'})
666 80 0 if ($self->{'tmpfiles'})
668 0 20 unless unlink $fn
681 36 80 if ($self->{'tmpfiles'})
683 0 0 unless unlink $fn
735 0 125 unless exists $self->{'parse_queue'}
746 20 153 if ($msg->{'type'} =~ m[^multipart/]i and defined $boundary and $subparse > 0) { }
754 4 149 if ($msg->{'type'} =~ m[^message/(?!partial\z)]i and $subparse > 0)
770 4 0 if ($msg->{'type'} =~ m[^message/(?:rfc822|global)\z]i and defined $msg->{'decoded'} and $msg->{'decoded'} ne '')
798 0 4 if (ref $msg->{'raw'} eq 'GLOB')
800 0 0 unless close $msg->{'raw'}
836 20 0 defined $boundary ? :
843 20 0 if (defined $boundary)
849 19 101 if (substr($body->[$line], 0, 2) eq '--' and $body->[$line] =~ /^--\Q$boundary\E\s*$/)
857 5 14 if ($line + 1 < $tmp_line and not $$body[$line + 1] =~ /^[\041-\071\073-\176]+:/)
866 19 1 if ($line < $tmp_line)
887 44 2216 if (--$line_count == 0 or $found_end_boundary)
896 0 44 if (not $found_end_boundary) { }
44 0 elsif ($part_array) { }
914 24 20 if $part_array->[-1] eq ''
925 44 0 defined $p_boundary ? :
936 44 0 if (defined $boundary)
938 20 24 if ($line =~ /^--\Q$boundary\E--\s*$/) { }
0 24 elsif ($line_count and not $$body[-$line_count] =~ /^[\041-\071\073-\176]+:/) { }
960 132 2084 unless ($in_body)
963 87 45 if (/^[\041-\071\073-\176]+[ \t]*:/) { }
1 44 elsif (/^[ \t]/ and $header) { }
964 49 38 if ($header)
977 38 6 if ($header)
985 43 1 if (/^\r?$/) { }
1010 8 12 if ($line_count)
1012 2 13 if ($$body[-$line_count] =~ /[^\s.]/)
1039 153 0 !($ct[0] =~ m[^multipart/]i) || defined $boundary ? :
1044 1 152 if ($disp =~ /name=\s*"?([^";]+)"?/i) { }
2 150 elsif ($ct[3]) { }
1050 3 150 if ($msg->{'name'})
1060 20 133 unless ($msg->{'type'} =~ m[^(?:text/(?:plain|html)$|message\b)])
1064 0 20 unless (eval { do { ($filepath, $fh) = Mail::SpamAssassin::Util::secure_tmpfile(); 1 } })
1065 0 0 $@ ne '' ? :
1068 20 0 if ($fh)
1074 0 20 unless $fh->print(@{$body;})
1075 0 20 unless $fh->flush
1081 133 20 if (not defined $msg->{'raw'})
1092 0 0 unless (exists $self->{'mimepart_digests'})
1110 247 128 if (exists $self->{$key})
1116 0 128 unless @parts
1122 8 120 $method_name eq 'invisible_rendered' ? :
1130 121 8 if $text ne ''
1133 129 0 if (defined $rnd)
1141 7 122 if ($html_needs_setting and $type eq 'text/html')
1181 2 96 if (defined $self->{'text_decoded'})
1186 0 96 unless @parts
1192 0 96 if $parts[$pt]{'type'} eq 'text/calendar'
1230 0 8 if ($j < 0)
1232 0 0 if ($j < 0)
1236 95 1 if $ofs < $text_l