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 ? :
284 0 824 if $self->{'SA_encode_results'}
288 824 0 if (exists $elements{$tag} or $maybe_namespace)
290 58 766 unless exists $self->{'inside'}{$tag}
293 58 766 unless exists $self->{'inside'}{$tag}
295 17 807 if ($self->{'inside'}{$tag} < 0)
300 0 824 if $maybe_namespace
303 824 0 if (exists $elements{$tag} or exists $tricks{$tag})
304 604 220 if exists $elements_text_style{$tag}
307 202 622 if exists $elements_whitespace{$tag}
310 464 360 if ($num == 1) { }
311 149 315 if exists $elements_uri{$tag}
316 13 347 if $tag eq 'html'
317 8 352 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 131 if $self->{'SA_encode_results'}
348 131 0 if $uri ne ''
359 0 249 if (length $uri > 8192)
371 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') { }
372 6 18 if (defined $attr->{'background'})
377 118 0 if (defined $attr->{'href'})
382 7 0 if (defined $attr->{'src'})
387 0 0 if (defined $attr->{'action'})
392 0 0 if (my $uri = $attr->{'href'})
402 0 0 if ($uri =~ m[^(?:https?|ftp):/{0,2}]i)
408 0 0 unless $uri =~ m[/$]
409 0 0 if $self->{'SA_encode_results'}
421 15 0 unless grep {$_->{'tag'} eq $tag;} @{$$self{'text_style'};}
425 0 0 if ($tag eq 'td' and $top eq 'font' || $top eq 'td' or $tag eq 'tr' and $top =~ /^(?:font|td|tr)$/) { }
440 15 277 unless grep {$_->{'tag'} eq $tag;} @{$$self{'text_style'};}
444 277 11 if $current{'tag'} eq $tag
452 0 604 if $tag eq 'th'
455 304 300 if ($num == 1) { }
458 7 297 if ($tag eq 'body')
463 0 0 if ($tag eq 'basefont' and exists $attr->{'size'} and $attr->{'size'} =~ /^\s*(\d+)/)
471 15 289 if $tag eq 'td' or $tag eq 'tr'
480 0 304 if ($tag eq 'big')
485 0 304 if ($tag eq 'small')
493 339 244 unless exists $ok_attributes{$tag}{$name}
494 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') { }
499 0 105 if ($attr->{'size'} =~ /^\s*([+-]\d+)/) { }
105 0 elsif ($attr->{'size'} =~ /^\s*(\d+)/) { }
512 0 8 if (/^\s*(background-)?color:\s*(.+)\s*$/i) { }
0 8 elsif (/^\s*([a-z_-]+)\s*:\s*(\S.*?)\s*$/i) { }
513 0 0 $1 ? :
516 0 0 if ($value =~ /rgb/) { }
520 0 0 $_ > 255 ? :
0 0 !$_ ? :
542 15 229 if ($new{'size'} > $self->{'max_size'}) { }
0 229 elsif ($new{'size'} < $self->{'min_size'}) { }
553 292 8 if ($tag ne 'body')
570 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})$/) { }
577 215 0 if ($bg =~ /^\#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/)
592 0 215 if ($distance < 12)
601 0 215 if ($fg eq 'invalid' or $bg eq 'invalid')
607 0 215 if ($size <= 1)
612 0 215 if ($display and lc $display eq 'none')
616 0 215 if ($visibility and lc $visibility eq 'hidden')
626 34 81 if ($tag eq 'font' and exists $attr->{'face'})
636 4 30 unless ($attr->{'face'} =~ /^\s*["'.]?[a-z ][a-z -]*[a-z]\d?["']?(?:,\s*["']?[a-z][a-z -]*[a-z]\d?["']?)*;?$/i)
640 1 6 if ($tag eq 'img' and exists $self->{'inside'}{'a'} and $self->{'inside'}{'a'} > 0)
642 0 1 if $self->{'SA_encode_results'}
647 7 0 if ($tag eq 'img' and exists $attr->{'width'} and exists $attr->{'height'})
653 0 7 if ($attr->{'width'} =~ /^(\d+)(\%)?$/)
655 0 0 if defined $2 and $2 eq '%'
657 0 7 if ($attr->{'height'} =~ /^(\d+)(\%)?$/)
659 0 0 if defined $2 and $2 eq '%'
662 7 0 if $width <= 0
663 7 0 if $height <= 0
664 7 0 if ($width > 0 and $height > 0)
669 0 0 if ($tag eq 'form' and exists $attr->{'action'})
670 0 0 if $attr->{'action'} =~ /mailto:/i
672 0 464 if ($tag eq 'object' or $tag eq 'embed')
677 118 346 if ($tag eq 'a')
679 118 0 exists $attr->{'href'} ? :
680 0 118 if $self->{'SA_encode_results'}
684 1 463 if ($tag eq 'title')
689 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)
695 1 0 exists $self->{'charsets'} ? :
705 686 0 unless (exists $display{'invisible'})
709 202 484 if ($display{'whitespace'}) { }
712 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))
726 185 292 if (@{$self->{'text'};} and not $display{'invisible'} and defined $self->{'text_whitespace'} and vec $self->{'text_whitespace'}, $#{$$self{'text'};}, 1)
736 13 875 unless (exists $self->{$textvar})
743 0 485 if $self->{'SA_encode_results'}
746 0 485 if (exists $self->{'inside'}{'script'} and $self->{'inside'}{'script'} > 0)
751 1 484 if (exists $self->{'inside'}{'style'} and $self->{'inside'}{'style'} > 0)
756 117 367 if (exists $self->{'inside'}{'a'} and $self->{'inside'}{'a'} > 0)
759 0 117 if $self->{'SA_encode_results'}
763 1 483 if (exists $self->{'inside'}{'title'} and $self->{'inside'}{'title'} > 0)
773 215 269 if (do { (my $tmp = $text) =~ s/(?:[ \t\n\r\f\x0b]|\xc2\xa0)//gs; length $tmp })
777 477 7 if (exists $self->{'text'}[-1])
782 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)
787 107 370 if ($self->{'text'}[-1] =~ /\b([^\s\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e]{1,7})\z/s)
791 0 107 if ($text =~ /^([^\s\x21-\x2f\x3a-\x40\x5b-\x60\x7b-\x7e]{1,7})\b/s)
797 0 484 if ($invisible_for_bayes) { }
808 0 1 if $self->{'SA_encode_results'}
815 0 0 if $self->{'SA_encode_results'}
817 0 0 if ($text =~ /^<!doctype/i)
1003 0 0 if (defined $hex)
1011 0 0 if length($color) % 3
1035 4 120 if (defined $hex)
1040 105 15 if ($color =~ /^[#a-f0-9]*$|rgb\([\d%, ]*\)/i) { }
1045 2 103 if ($color =~ /rgb\((\d+)%,\s*(\d+)%,\s*(\d+)%\s*\)/i)
1050 2 103 if ($color =~ /rgb\((\d+),\s*(\d+),\s*(\d+)\s*\)/i)
1055 99 6 if ($color =~ /^#/) { }
1060 1 98 if (length $color > 6)
1065 0 99 if (length $color > 3 and length $color < 6)
1070 1 98 if length($color) % 3
1073 3 96 if (length $color == 3)
1100 0 12 if ($dec < 16)
1127 9 289 if ($input =~ s[^/\.(?:$|/)][/]) { }
20 269 elsif ($input =~ s[^/\.\.(?:$|/)][/]) { }
269 0 elsif ($input =~ s[(/?[^/]*)][]) { }
1142 0 92 if (defined $base_authority and not $base_path) { }
1146 34 58 if ($base_path =~ m[/]) { }
1163 1 74 if (defined $r{'scheme'} and defined $base{'scheme'} and $r{'scheme'} eq $base{'scheme'})
1170 74 99 if (defined $r{'scheme'}) { }
1177 1 98 if (defined $r{'authority'}) { }
1183 3 95 if ($r{'path'} eq '') { }
1185 1 2 if (defined $r{'query'}) { }
1193 3 92 if ($r{'path'} =~ m[^/]) { }
1210 115 58 if ($t{'scheme'}) { }
0 58 elsif (defined $t{'authority'}) { }
1217 0 0 if ($t{'authority'} =~ /^www\d*\./i) { }
0 0 elsif ($t{'authority'} =~ /^ftp\d*\./i) { }
1225 106 67 if ($t{'authority'})
1229 12 161 if (defined $t{'query'})
1232 6 167 if (defined $t{'fragment'})