Branch Coverage

blib/lib/Mail/SpamAssassin/HTML.pm
Criterion Covered Total %
branch 195 308 63.3


line true false branch
135 7 0 if (defined $self->{'uri'})
151 7 0 if (exists $self->{'tags'})
165 0 7 if (exists $self->{'backhair'})
168 7 0 if (exists $self->{'elements'} and exists $self->{'tags'})
172 7 0 if (exists $self->{'elements_seen'} and exists $self->{'tags_seen'})
177 0 7 if (exists $self->{'tags'} and exists $self->{'obfuscation'})
202 7 14 unless %options
206 0 14 unless defined $$self{"text_$k"}
207 14 0 if (not defined $mask) { }
208 7 7 $v ? :
211 0 0 $v ? :
217 686 686 if vec $mask, $i++, 1
251 0 7 if (not $self->UNIVERSAL::can('utf8_mode')) { }
254 0 0 unless $self->{'SA_character_semantics_input'}
256 0 7 $self->{'SA_character_semantics_input'} ? :
258 7 0 $utf8_mode ? :
276 0 824 if $self->{'SA_encode_results'}
280 824 0 if (exists $elements{$tag} or $maybe_namespace)
282 58 766 unless exists $self->{'inside'}{$tag}
285 58 766 unless exists $self->{'inside'}{$tag}
287 17 807 if ($self->{'inside'}{$tag} < 0)
292 0 824 if $maybe_namespace
295 824 0 if (exists $elements{$tag} or exists $tricks{$tag})
296 604 220 if exists $elements_text_style{$tag}
299 202 622 if exists $elements_whitespace{$tag}
302 464 360 if ($num == 1) { }
303 149 315 if exists $elements_uri{$tag}
308 13 347 if $tag eq 'html'
309 8 352 if $tag eq 'body'
318 93 109 if ($tag eq 'br' or $tag eq 'div') { }
15 94 elsif ($tag =~ /^(?:li|t[hd]|d[td]|embed|h\d)$/) { }
94 0 elsif ($tag =~ /^(?:p|hr|blockquote|pre|listing|plaintext|xmp|title)$/) { }
335 0 131 if $self->{'SA_encode_results'}
340 131 0 if $uri ne ''
351 0 249 if (length $uri > 8192)
363 24 125 if ($tag =~ /^(?:body|table|tr|td)$/) { }
118 7 elsif ($tag =~ /^(?:a|area|link)$/) { }
7 0 elsif ($tag =~ /^(?:img|frame|iframe|embed|script|bgsound)$/) { }
0 0 elsif ($tag eq 'form') { }
0 0 elsif ($tag eq 'base') { }
364 6 18 if (defined $attr->{'background'})
369 118 0 if (defined $attr->{'href'})
374 7 0 if (defined $attr->{'src'})
379 0 0 if (defined $attr->{'action'})
384 0 0 if (my $uri = $attr->{'href'})
394 0 0 if ($uri =~ m[^(?:https?|ftp):/{0,2}]i)
400 0 0 unless $uri =~ m[/$]
401 0 0 if $self->{'SA_encode_results'}
413 15 0 unless grep {$_->{'tag'} eq $tag;} @{$$self{'text_style'};}
417 0 0 if ($tag eq 'td' and $top eq 'font' || $top eq 'td' or $tag eq 'tr' and $top =~ /^(?:font|td|tr)$/) { }
432 15 277 unless grep {$_->{'tag'} eq $tag;} @{$$self{'text_style'};}
436 277 11 if $current{'tag'} eq $tag
444 0 604 if $tag eq 'th'
447 304 300 if ($num == 1) { }
450 7 297 if ($tag eq 'body')
455 0 0 if ($tag eq 'basefont' and exists $attr->{'size'} and $attr->{'size'} =~ /^\s*(\d+)/)
463 15 289 if $tag eq 'td' or $tag eq 'tr'
472 0 304 if ($tag eq 'big')
477 0 304 if ($tag eq 'small')
485 339 244 unless exists $ok_attributes{$tag}{$name}
486 90 154 if ($name eq 'text' or $name eq 'color') { }
105 49 elsif ($name eq 'size') { }
8 41 elsif ($name eq 'style') { }
6 35 elsif ($name eq 'bgcolor') { }
491 0 105 if ($attr->{'size'} =~ /^\s*([+-]\d+)/) { }
105 0 elsif ($attr->{'size'} =~ /^\s*(\d+)/) { }
504 0 8 if (/^\s*(background-)?color:\s*(.+)\s*$/i) { }
0 8 elsif (/^\s*([a-z_-]+)\s*:\s*(\S.*?)\s*$/i) { }
505 0 0 $1 ? :
508 0 0 if ($value =~ /rgb/) { }
512 0 0 $_ > 255 ? :
0 0 !$_ ? :
534 15 229 if ($new{'size'} > $self->{'max_size'}) { }
0 229 elsif ($new{'size'} < $self->{'min_size'}) { }
545 292 8 if ($tag ne 'body')
562 0 215 if (substr($fg, -6) eq substr($bg, -6)) { }
215 0 elsif ($fg =~ /^\#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/) { }
569 215 0 if ($bg =~ /^\#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/)
584 0 215 if ($distance < 12)
593 0 215 if ($fg eq 'invalid' or $bg eq 'invalid')
599 0 215 if ($size <= 1)
604 0 215 if ($display and lc $display eq 'none')
608 0 215 if ($visibility and lc $visibility eq 'hidden')
618 34 81 if ($tag eq 'font' and exists $attr->{'face'})
619 24 10 unless ($attr->{'face'} =~ /^'?[a-z ][a-z -]*[a-z](?:,\s*[a-z][a-z -]*[a-z])*'?$/i)
623 1 6 if ($tag eq 'img' and exists $self->{'inside'}{'a'} and $self->{'inside'}{'a'} > 0)
625 0 1 if $self->{'SA_encode_results'}
630 7 0 if ($tag eq 'img' and exists $attr->{'width'} and exists $attr->{'height'})
636 0 7 if ($attr->{'width'} =~ /^(\d+)(\%)?$/)
638 0 0 if defined $2 and $2 eq '%'
640 0 7 if ($attr->{'height'} =~ /^(\d+)(\%)?$/)
642 0 0 if defined $2 and $2 eq '%'
645 7 0 if $width <= 0
646 7 0 if $height <= 0
647 7 0 if ($width > 0 and $height > 0)
652 0 0 if ($tag eq 'form' and exists $attr->{'action'})
653 0 0 if $attr->{'action'} =~ /mailto:/i
655 0 464 if ($tag eq 'object' or $tag eq 'embed')
660 118 346 if ($tag eq 'a')
662 118 0 exists $attr->{'href'} ? :
663 0 118 if $self->{'SA_encode_results'}
667 1 463 if ($tag eq 'title')
672 1 1 if ($tag eq 'meta' and exists $attr->{'http-equiv'} and exists $attr->{'content'} and $attr->{'http-equiv'} =~ /Content-Type/i and $attr->{'content'} =~ /\bcharset\s*=\s*["']?([^"']+)/i)
678 1 0 exists $self->{'charsets'} ? :
688 686 0 unless (exists $display{'invisible'})
692 202 484 if ($display{'whitespace'}) { }
695 185 17 if (@{$self->{'text'};} and not defined $self->{'text_whitespace'} && vec($self->{'text_whitespace'}, $#{$$self{'text'};}, 1) and not defined $self->{'text_invisible'} && vec($self->{'text_invisible'}, $#{$$self{'text'};}, 1))
709 185 292 if (@{$self->{'text'};} and not $display{'invisible'} and defined $self->{'text_whitespace'} and vec $self->{'text_whitespace'}, $#{$$self{'text'};}, 1)
719 13 875 unless (exists $self->{$textvar})
726 0 485 if $self->{'SA_encode_results'}
729 0 485 if (exists $self->{'inside'}{'script'} and $self->{'inside'}{'script'} > 0)
734 1 484 if (exists $self->{'inside'}{'style'} and $self->{'inside'}{'style'} > 0)
739 117 367 if (exists $self->{'inside'}{'a'} and $self->{'inside'}{'a'} > 0)
742 0 117 if $self->{'SA_encode_results'}
746 1 483 if (exists $self->{'inside'}{'title'} and $self->{'inside'}{'title'} > 0)
753 215 269 unless ($text =~ /^(?:[ \t\n\r\f\x0b]|\xc2\xa0)*\z/s)
757 477 7 if (exists $self->{'text'}[-1])
762 0 477 if ($text =~ /^[^\s\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e]/s and $self->{'text'}[-1] =~ /[^\s\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e]\z/s)
767 107 370 if ($self->{'text'}[-1] =~ /\b([^\s\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e]{1,7})\z/s)
771 0 107 if ($text =~ /^([^\s\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e]{1,7})\b/s)
777 0 484 if ($invisible_for_bayes) { }
788 0 1 if $self->{'SA_encode_results'}
795 0 0 if $self->{'SA_encode_results'}
797 0 0 if ($text =~ /^<!doctype/i)
983 0 0 if (defined $hex)
991 0 0 if length($color) % 3
1015 4 120 if (defined $hex)
1020 105 15 if ($color =~ /^[#a-f0-9]*$|rgb\([\d%, ]*\)/i) { }
1025 2 103 if ($color =~ /rgb\((\d+)%,\s*(\d+)%,\s*(\d+)%\s*\)/i)
1030 2 103 if ($color =~ /rgb\((\d+),\s*(\d+),\s*(\d+)\s*\)/i)
1035 99 6 if ($color =~ /^#/) { }
1040 1 98 if (length $color > 6)
1045 0 99 if (length $color > 3 and length $color < 6)
1050 1 98 if length($color) % 3
1053 3 96 if (length $color == 3)
1080 0 12 if ($dec < 16)
1107 9 289 if ($input =~ s[^/\.(?:$|/)][/]) { }
20 269 elsif ($input =~ s[^/\.\.(?:$|/)][/]) { }
269 0 elsif ($input =~ s[(/?[^/]*)][]) { }
1122 0 92 if (defined $base_authority and not $base_path) { }
1126 34 58 if ($base_path =~ m[/]) { }
1143 1 74 if (defined $r{'scheme'} and defined $base{'scheme'} and $r{'scheme'} eq $base{'scheme'})
1150 74 99 if (defined $r{'scheme'}) { }
1157 1 98 if (defined $r{'authority'}) { }
1163 3 95 if ($r{'path'} eq '') { }
1165 1 2 if (defined $r{'query'}) { }
1173 3 92 if ($r{'path'} =~ m[^/]) { }
1190 115 58 if ($t{'scheme'}) { }
0 58 elsif (defined $t{'authority'}) { }
1197 0 0 if ($t{'authority'} =~ /^www\d*\./i) { }
0 0 elsif ($t{'authority'} =~ /^ftp\d*\./i) { }
1205 106 67 if ($t{'authority'})
1209 12 161 if (defined $t{'query'})
1212 6 167 if (defined $t{'fragment'})