Branch Coverage

blib/lib/HTML/StripScripts.pm
Criterion Covered Total %
branch 169 202 83.6


line true false branch
445 48 3112 unless $self->_hss_accept_input_start($text)
451 7 3153 unless $text =~ /^<([a-zA-Z0-9]+)\b(.*)>$/m
454 0 3153 if $$self{'_hssSkipToEnd'}
455 0 3153 if ($tag eq 'script' or $tag eq 'style')
460 34 3119 if $self->_hss_tag_is_banned($tag)
463 2 3117 unless defined $allowed_attr
465 3 3114 unless $self->_hss_get_to_valid_context($tag)
476 2 1 defined $4 ? :
4350 3 defined $3 ? :
12 4353 defined $2 ? :
483 1 4364 unless defined $value_class
486 0 4364 unless defined $attval_handler
489 4115 249 if ($tag_filters)
495 796 3319 unless $attr_filter
499 13 3555 unless defined $filtered_value
502 2392 1163 if ($tag_filters and ref $attr_filter)
505 529 1863 unless defined $filtered_value
513 3 3111 if (my $required = $$tag_filters{'required'})
515 2 3 unless defined $filtered_attr{$key} and length $filtered_attr{$key}
532 1576 1536 if ($new_context eq 'EMPTY') { }
553 30 1478 unless $self->_hss_accept_input_end($text)
559 3 1505 unless $text =~ m[^$]
562 0 1505 if ($$self{'_hssSkipToEnd'})
563 0 0 if ($$self{'_hssSkipToEnd'} eq $tag)
570 27 1478 unless grep {$$_{'NAME'} eq $tag;} @{$$self{'_hssStack'};}
580 1478 2 if $$entry{'NAME'} eq $tag
585 89 1389 unless (grep {not $$self{'_hssDeInter'}{$$_{'NAME'}};} @close)
602 0 382 if $$self{'_hssSkipToEnd'}
606 2 380 if ($text =~ /^(\s*)$/)
611 1 379 unless ($self->_hss_get_to_valid_context('CDATA'))
812 41 3072 if (my $tag_callback = $$tag{'CALLBACK'})
813 1 40 unless &$tag_callback($self, \%entry)
820 1576 1536 if ($$tag{'CTX'} eq 'EMPTY')
821 1576 0 if $entry{'tag'}
825 1535 1 if ($tagname)
829 1536 0 if (defined $entry{'content'})
833 1535 1 if ($tagname)
876 2 74 $_[0]{'_hssCfg'}{'EscapeFiltered'} ? :
1340 210 11 defined $3 ? :
90 221 defined $2 ? :
4753 311 defined $1 ? :
1400 90 3404 defined $1 ? :
1445 3 15 if $$self{'_hssCfg'}{'AllowRelURL'} and $text =~ m[^((?:[\w\-.!~*|;/?=+\$,%#]|&){0,100})$]
1449 5 10 $text =~ m[ ^ ( https? :// [\w\-\.]{1,100} (?:\:\d{1,5})? (?: / (?:[\w\-.!~*|;/?=+\$,%#]|&){0,100} )? ) $ ]x ? :
1474 2 0 if $text =~ m[^( mailto:[\w\-!#$%&'*+-/=?^_`{|}~.]{1,64} # localpart \@ # @ [\w\-\.]{1,100} # domain (?: # opt query string \? (?:[\w\-.!~*|;/?=+\$,%#]|&){0,100} )? )$]x
1606 5 0 if ($elt =~ /^\s*([\w\-]+)\s*:\s*(.+?)\s*$/s)
1610 1 4 unless defined $value_class
1612 0 4 unless defined $sub
1615 4 0 if (defined $cleanval)
1632 2 0 $_[3] =~ /^\s*([+-]?\d{1,20}(?:\.\d{1,20)?)\s*((?:\%|\*|ex|px|pc|cm|mm|in|pt|em)?)\s*$/i ? :
1646 0 0 $_[3] =~ /^\s*\+?(\d{1,20})\s*$/ ? :
1656 12 0 $_[3] =~ /^\s*(\w{2,20}|#[\da-fA-F]{6})\s*$/ ? :
1666 1304 0 length $_[3] <= 200 ? :
1677 2225 0 $_[3] =~ /^\s*([\w\-]{1,30})\s*$/ ? :
1688 0 0 $_[3] =~ /^\s*([\w\-\, ]{1,200})\s*$/ ? :
1705 0 0 scalar @words ? :
1719 2 19 if ($$filter{'_hssCfg'}{'AllowMailto'} and substr($attval, 0, 7) eq 'mailto:') { }
17 2 elsif ($$filter{'_hssCfg'}{'AllowHref'}) { }
1742 2 1 if ($$filter{'_hssCfg'}{'AllowSrc'}) { }
1759 0 0 if ($attval =~ /^\s*url\((.+)\)\s*$/) { }
1822 3 1484 ref $ban_list eq 'ARRAY' ? :
1827 1431 56 if (my $rules = $$cfg{'Rules'})
1828 12 1325 if (exists $$rules{'*'} and ref $$rules{'*'} eq 'HASH' && exists $$rules{'*'}{'tag'} && !$$rules{'*'}{'tag'} || !$$rules{'*'})
1842 15 1472 if ($$cfg{'BanAllBut'})
1845 4 2 unless $$prepared_ban_list{$dontban}
1870 5 1426 unless $rules and ref $rules eq 'HASH' and keys %$rules
1874 0 1426 unless ref $rules eq 'HASH'
1885 14 2672 unless ($rule)
1891 2658 14 if (my $rule_ref = ref $rule) { }
1894 21 2637 if $rule_ref eq 'CODE'
1897 0 2658 unless ref $rule eq 'HASH'
1910 3 2655 if (my $required = delete $$rule{'required'})
1911 3 0 if (ref $required eq 'ARRAY' and @$required)
1923 927 3564 if ($ref_type eq 'CODE')
1928 2676 888 unless ($ref_type)
1931 1788 888 if ($value eq '0' or $value eq '1')
1937 0 888 unless $value = eval { do { qr/$value/ } }
1942 0 1776 unless $ref_type eq 'Regexp'
1948 1064 528 $attval =~ /$value/ ? :
1954 2644 14 if keys %prepared_rule
1958 15 1411 unless keys %prepared_rules
1962 301 1110 unless (exists $prepared_rules{'*'}{'*'})
1970 1399 12 unless ref $prepared_rules{'*'}{'tag'}
1990 2284 1831 if exists $$tag_filters{$key}
1993 1633 198 if exists $$tag_filters{'*'}
1996 0 198 if exists $$default_filters{$key}
2032 210 90 $numeric =~ s/^x//i ? :
2035 210 90 $hex ? :
2037 40 260 if ($number == 38) { }
236 24 elsif ($number < 127) { }
2044 16 8 $hex ? :
2058 34 3119 exists $$self{'_hssBanList'}{$tag} ? :
2078 21 3476 if ($tag eq 'a')
2080 0 21 if $$ancestor{'NAME'} eq 'a'
2084 3489 8 if $self->_hss_valid_in_current_context($tag)
2086 2 6 if ($self->_hss_context eq 'Document')
2088 1 1 if $self->_hss_valid_in_current_context($tag)
2091 2 5 if ($self->_hss_context eq 'Html' and $self->_hss_valid_in_context($tag, 'Flow'))
2100 4 1 unless grep {$self->_hss_valid_in_context($tag, $$_{'CTX'});} @{$$self{'_hssStack'};}
2118 0 1 unless scalar @{$$self{'_hssStack'};}
2143 3494 17 $$self{'_hssContext'}{$context}{$tag} ? :