Branch Coverage

blib/lib/Mail/SpamAssassin/HTML.pm
Criterion Covered Total %
branch 197 314 62.7


line true false branch
135 8 0 if (defined $self->{'uri'})
151 8 0 if (exists $self->{'tags'})
165 0 8 if (exists $self->{'backhair'})
168 8 0 if (exists $self->{'elements'} and exists $self->{'tags'})
172 8 0 if (exists $self->{'elements_seen'} and exists $self->{'tags_seen'})
177 0 8 if (exists $self->{'tags'} and exists $self->{'obfuscation'})
202 8 16 unless %options
206 0 16 unless defined $$self{"text_$k"}
207 16 0 if (not defined $mask) { }
208 8 8 $v ? :
211 0 0 $v ? :
217 863 863 if vec $mask, $i++, 1
251 0 8 if (not $self->UNIVERSAL::can('utf8_mode')) { }
254 0 0 unless $self->{'SA_character_semantics_input'}
256 0 8 $self->{'SA_character_semantics_input'} ? :
258 8 0 $utf8_mode ? :
284 0 1001 if $self->{'SA_encode_results'}
288 1001 0 if (exists $elements{$tag} or $maybe_namespace)
290 63 938 unless exists $self->{'inside'}{$tag}
293 63 938 unless exists $self->{'inside'}{$tag}
295 17 984 if ($self->{'inside'}{$tag} < 0)
300 0 1001 if $maybe_namespace
303 1001 0 if (exists $elements{$tag} or exists $tricks{$tag})
304 776 225 if exists $elements_text_style{$tag}
307 202 799 if exists $elements_whitespace{$tag}
310 553 448 if ($num == 1) { }
311 235 318 if exists $elements_uri{$tag}
316 14 434 if $tag eq "html"
317 9 439 if $tag eq "body"
326 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)$/) { }
343 0 301 if $self->{'SA_encode_results'}
348 301 0 if $uri ne ""
359 0 504 if (length $uri > 8192)
371 25 210 if ($tag =~ /^(?:body|table|tr|td)$/) { }
203 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') { }
372 6 19 if (defined $attr->{'background'})
377 203 0 if (defined $attr->{'href'})
380 85 118 if (defined $attr->{'data-saferedirecturl'})
385 7 0 if (defined $attr->{'src'})
390 0 0 if (defined $attr->{'action'})
395 0 0 if (my $uri = $attr->{'href'})
405 0 0 if ($uri =~ m[^(?:https?|ftp):/{0,2}]i)
411 0 0 unless $uri =~ m[/$]
412 0 0 if $self->{'SA_encode_results'}
424 15 0 unless grep {$_->{'tag'} eq $tag;} @{$$self{"text_style"};}
428 0 0 if ($tag eq 'td' and $top eq 'font' || $top eq 'td' or $tag eq 'tr' and $top =~ /^(?:font|td|tr)$/) { }
443 15 362 unless grep {$_->{'tag'} eq $tag;} @{$$self{"text_style"};}
447 362 11 if $current{'tag'} eq $tag
455 0 776 if $tag eq "th"
458 390 386 if ($num == 1) { }
461 8 382 if ($tag eq "body")
466 0 0 if ($tag eq "basefont" and exists $attr->{'size'} and $attr->{'size'} =~ /^\s*(\d+)/)
474 15 375 if $tag eq "td" or $tag eq "tr"
483 0 390 if ($tag eq "big")
488 0 390 if ($tag eq "small")
496 509 244 unless exists $ok_attributes{$tag}{$name}
497 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') { }
502 0 105 if ($attr->{'size'} =~ /^\s*([+-]\d+)/) { }
105 0 elsif ($attr->{'size'} =~ /^\s*(\d+)/) { }
515 0 8 if (/^\s*(background-)?color:\s*(.+?)\s*$/i) { }
0 8 elsif (/^\s*([a-z_-]+)\s*:\s*(\S.*?)\s*$/i) { }
516 0 0 $1 ? :
519 0 0 if ($value =~ /rgb/) { }
0 0 elsif ($value eq 'inherit') { }
0 0 elsif ($value eq '!important') { }
523 0 0 $_ > 255 ? :
0 0 !$_ ? :
553 15 229 if ($new{'size'} > $self->{'max_size'}) { }
0 229 elsif ($new{'size'} < $self->{'min_size'}) { }
564 377 9 if ($tag ne "body")
581 0 300 if (substr($fg, -6) eq substr($bg, -6)) { }
300 0 elsif ($fg =~ /^\#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/) { }
588 300 0 if ($bg =~ /^\#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/)
603 0 300 if ($distance < 12)
612 0 300 if ($fg eq "invalid" or $bg eq "invalid")
618 0 300 if ($size <= 1)
623 0 300 if ($display and lc $display eq "none")
627 0 300 if ($visibility and lc $visibility eq "hidden")
637 34 81 if ($tag eq "font" and exists $attr->{'face'})
647 4 30 unless ($attr->{'face'} =~ /^\s*["'.]?[a-z ][a-z -]*[a-z]\d?["']?(?:,\s*["']?[a-z][a-z -]*[a-z]\d?["']?)*;?$/i)
651 1 6 if ($tag eq "img" and exists $self->{'inside'}{'a'} and $self->{'inside'}{'a'} > 0)
653 0 1 if $self->{'SA_encode_results'}
658 7 0 if ($tag eq "img" and exists $attr->{'width'} and exists $attr->{'height'})
664 0 7 if ($attr->{'width'} =~ /^(\d+)(\%)?$/)
666 0 0 if defined $2 and $2 eq "%"
668 0 7 if ($attr->{'height'} =~ /^(\d+)(\%)?$/)
670 0 0 if defined $2 and $2 eq "%"
673 7 0 if $width <= 0
674 7 0 if $height <= 0
675 7 0 if ($width > 0 and $height > 0)
680 0 0 if ($tag eq "form" and exists $attr->{'action'})
681 0 0 if $attr->{'action'} =~ /mailto:/i
683 0 553 if ($tag eq "object" or $tag eq "embed")
688 203 350 if ($tag eq "a")
690 203 0 exists $attr->{'href'} ? :
691 0 203 if $self->{'SA_encode_results'}
695 1 552 if ($tag eq "title")
700 2 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)
706 2 0 exists $self->{'charsets'} ? :
716 863 0 unless (exists $display{'invisible'})
720 202 661 if ($display{'whitespace'}) { }
723 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))
737 185 468 if (@{$self->{'text'};} and not $display{'invisible'} and defined $self->{'text_whitespace'} and vec $self->{'text_whitespace'}, $#{$$self{"text"};}, 1)
747 14 1051 unless (exists $self->{$textvar})
754 0 662 if $self->{'SA_encode_results'}
757 0 662 if (exists $self->{'inside'}{'script'} and $self->{'inside'}{'script'} > 0)
762 1 661 if (exists $self->{'inside'}{'style'} and $self->{'inside'}{'style'} > 0)
767 202 459 if (exists $self->{'inside'}{'a'} and $self->{'inside'}{'a'} > 0)
770 0 202 if $self->{'SA_encode_results'}
774 1 660 if (exists $self->{'inside'}{'title'} and $self->{'inside'}{'title'} > 0)
784 300 361 if (do {
788 653 8 if (exists $self->{'text'}[-1])
793 0 653 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)
798 192 461 if ($self->{'text'}[-1] =~ /\b([^\s\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e]{1,7})\z/s)
802 0 192 if ($text =~ /^([^\s\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e]{1,7})\b/s)
808 0 661 if ($invisible_for_bayes) { }
819 0 1 if $self->{'SA_encode_results'}
826 0 0 if $self->{'SA_encode_results'}
828 0 0 if ($text =~ /^<!doctype/i)
1014 0 0 if (defined $hex)
1022 0 0 if length($color) % 3
1046 4 120 if (defined $hex)
1051 105 15 if ($color =~ /^[#a-f0-9]*$|rgb\([\d%, ]*\)/i) { }
1056 2 103 if ($color =~ /rgb\((\d+)%,\s*(\d+)%,\s*(\d+)%\s*\)/i)
1061 2 103 if ($color =~ /rgb\((\d+),\s*(\d+),\s*(\d+)\s*\)/i)
1066 99 6 if ($color =~ /^#/) { }
1071 1 98 if (length $color > 6)
1076 0 99 if (length $color > 3 and length $color < 6)
1081 1 98 if length($color) % 3
1084 3 96 if (length $color == 3)
1111 0 12 if ($dec < 16)
1138 9 373 if ($input =~ s[^/\.(?:$|/)][/]) { }
20 353 elsif ($input =~ s[^/\.\.(?:$|/)][/]) { }
353 0 elsif ($input =~ s[(/?[^/]*)][]) { }
1153 0 149 if (defined $base_authority and not $base_path) { }
1157 34 115 if ($base_path =~ m[/]) { }
1174 1 187 if (defined $r{'scheme'} and defined $base{'scheme'} and $r{'scheme'} eq $base{'scheme'})
1181 187 156 if (defined $r{'scheme'}) { }
1188 1 155 if (defined $r{'authority'}) { }
1194 3 152 if ($r{'path'} eq '') { }
1196 1 2 if (defined $r{'query'}) { }
1204 3 149 if ($r{'path'} =~ m[^/]) { }
1221 228 115 if ($t{'scheme'}) { }
0 115 elsif (defined $t{'authority'}) { }
1228 0 0 if ($t{'authority'} =~ /^www\d*\./i) { }
0 0 elsif ($t{'authority'} =~ /^ftp\d*\./i) { }
1236 212 131 if ($t{'authority'})
1240 14 329 if (defined $t{'query'})
1243 6 337 if (defined $t{'fragment'})