Branch Coverage

blib/lib/HTML/Defang.pm
Criterion Covered Total %
branch 296 434 68.2


line true false branch
143 0 6 if eval 'use Scalar::Readonly qw(readonly_on);'
798 10 13 if $tags_to_callback
800 0 23 if $attribs_to_callback
802 0 23 if $empty_tags_to_collapse
804 1 22 if $mismatched_tags_to_fix
828 0 23 defined $Opts{'defang_default'} ? :
865 0 0 if $lcTag eq 'title' and not $IsEndTag
1165 0 309 if $Debug
1167 0 309 if $Debug
1172 0 309 $Opts->{'add_to_existing'} ? :
1188 0 309 if $HasScalarReadonly
1202 0 309 unless defined $I
1218 1044 309 if ($I =~ /\G(.*?)
1224 0 1044 if $Self->{'content_callback'}
1231 217 827 $I =~ m[\G/]cogs ? :
1234 1013 31 if ($I =~ /\G($TagNameRE)/cogs) { }
21 10 elsif ($I =~ /\G(!)((?:\[CDATA\[|--)?)/cgis) { }
8 2 elsif ($I =~ /\G(\?)/cgs) { }
1237 557 456 $I =~ m[\G([\s/]+)]cogs ? :
1239 0 1013 if $Debug
1243 461 552 if $I =~ /\G>/cogs
1249 552 1 unless defined $1 or defined $4
1252 668 9 if (defined $4 and $4 =~ /^([`"']?)(.*)\1$/s)
1254 5 663 $1 eq '`' ? :
1259 4 673 if $UTF8Input
1260 4 673 if $UTF8Input
1263 0 677 if $Debug
1267 548 4 if ($I =~ m(\G(?:(\s*[/\\]*\s*(?:--)?\s*)?>|([\s/-]*)))cgs)
1268 0 535 $2 ? :
13 535 $1 ? :
1278 271 742 if (not exists $Self->{'tags_to_callback'}{$lcTag} and ref $TagOps eq 'CODE') { }
1280 0 271 if $Debug
1285 0 742 if $Debug
1289 0 1013 unless defined pos $I
1290 0 1013 if $Debug
1297 91 922 if ($Self->{'fix_mismatched_tags'} and $Defang == 0)
1298 70 21 if (not $IsEndTag) { }
1302 4 17 if $Defang == 1
1307 158 851 if ($Defang != 0)
1308 0 158 if $Debug
1309 0 158 if ($Self->{'delete_defang_content'}) { }
1313 158 0 if $Self->{'allow_double_defang'} or not $Tag =~ /$Self->{'defang_re'}/
1329 0 21 if $Debug
1333 4 17 $IsCDATA ? :
1335 0 21 if $Debug
1340 21 0 unless ($Self->{'delete_defang_content'})
1345 18 3 if ($I =~ /\G(.*?)(\Q$ClosingCommentDelim\E!?\s*)(>)/cgis or $I =~ /\G(.*?)(--)(>)/cgis) { }
1355 18 0 unless ($Self->{'delete_defang_content'})
1367 0 3 unless $I =~ /\G(.*)$/cgs
1373 3 0 unless ($Self->{'delete_defang_content'})
1382 0 8 if $Debug
1385 6 2 if ($I =~ /\G(.*?\??)>/cgs) { }
1394 8 0 unless ($Self->{'delete_defang_content'})
1401 3 1041 if (exists $Self->{'TrackedAppendOutput'})
1406 137 907 if (exists $Self->{'AppendOutput'})
1409 0 1044 if (exists $Self->{'DelayedAppendOutput'})
1416 0 309 if $Debug
1419 299 10 if $1
1426 309 0 if ($Self->{'Reentrant'}-- <= 1)
1431 2 307 if $UTF8Input
1460 137 2 unless defined $Self->{'AppendOutput'}
1466 0 0 unless defined $Self->{'DelayedAppendOutput'}
1542 0 49 if $Self->{'Debug'}
1544 25 24 unless ($IsEndTag)
1552 22 3 if ($$HtmlR =~ m[\G(.*?)(?=
1554 0 22 if $Self->{'Debug'}
1555 22 0 unless ($Self->{'delete_defang_content'})
1570 0 222 if $Self->{'Debug'}
1576 110 112 if $IsEndTag
1585 110 2 if (m[\G(.*?)(?=
2 0 elsif (/\G([^<]*)/cgis) { }
1597 4 108 $Content =~ s/^(\s*\s*)$// ? :
1601 0 112 if (length $Content > 16384)
1604 0 0 if ($TagCount > length($Content) / 256)
1612 2 110 unless $ClosingStyleTagPresent
1649 0 316 if $Self->{'Debug'}
1652 137 179 $Naked ? :
1658 2 705 if ($Content =~ /$RECStyleMediaSelector/cogs) { }
2 703 elsif (@InMedia and $Content =~ /\G(\s*)(\})(\s*)/cgs) { }
522 181 elsif ($Content =~ /$SelectorRuleRE/cgs) { }
2 179 elsif (not $Naked and $Content =~ /\G\s*$StyleSelectors\s*$/cgs) { }
0 179 elsif (not $Naked and $Content =~ m[\G(?:\{\}]*)?>\s*)+]cgs) { }
0 179 elsif ($Content =~ /\G\s+/cgs) { }
0 179 elsif ($Content =~ /\G[^\s<]+/cgs or $Content =~ /\G<+/cgs) { }
1670 137 385 if $Selector eq '' and $SelectorRule =~ /^[;\s]*$/
1671 2 383 if @InMedia
1675 0 385 if $Self->{'Debug'}
1676 0 385 if $Self->{'Debug'}
1702 389 0 if $Spaces
1703 0 389 unless $Spaces
1704 0 0 unless $Spaces or $IsAttr
1707 389 0 if (defined $Selector)
1708 389 0 if defined $BeforeSelector
1709 2 387 $Selector =~ /\000/ ? :
1710 389 0 if defined $AfterSelector
1711 389 0 if defined $OpenBrace
1712 350 39 if defined $SelectorRule
1713 389 0 if defined $CloseBrace
1714 389 0 if defined $AfterRule
1719 0 316 if $Self->{'Debug'}
1751 0 31 if $V and $V > 127
1752 31 0 $V && $V < 1114111 && $V != 65535 && !($V > 55295 && $V < 57344) ? :
1758 112 204 unless ($_[1])
1762 1 125 if $V and $V > 127
1763 126 0 $V && $V < 1114111 && $V != 65535 && !($V > 55295 && $V < 57344) ? :
1765 0 1 unless $EntityToChar{lc $1}
1776 1 315 if $UnicodeEntity
1778 0 316 if $Self->{'Debug'}
1831 0 389 if $Self->{'Debug'}
1839 0 548 if $Self->{'Debug'}
1845 11 537 if ($Self->{'url_callback'})
1848 11 0 $2 ? :
1850 0 11 if $Self->{'Debug'}
1851 2 9 $IsAttr ? :
1852 11 0 if $Url
1854 0 11 if $Self->{'Debug'}
1855 11 0 if ($UrlOrig)
1864 0 548 if $Self->{'Debug'}
1876 163 153 if $Self->{'css_callback'}
1879 0 316 if $Self->{'Debug'} and $#Selectors > $#SelectorRules
1898 494 111 defined $v->[1] ? :
1900 255 350 if ($k < @$KeyValueRules - 1)
1901 91 164 unless defined $v->[4] and $v->[4] =~ /;/
1914 105 284 if $SelectorsIn->[$Counter] and not $IsAttr
1925 0 605 unless $v
1928 329 276 if ($Defang == 2)
1929 326 3 $Value =~ m[^\s*[a-z0-9%!"'`:()#\s.,\/+-]+\s*;?\s*$]i ? :
1930 25 304 $Value =~ /\burl\s*\(/i ? :
1931 3 326 $Value =~ /\bexpression\s*\(/i ? :
1935 4339 501 defined $_ ? :
1940 109 496 if ($Defang != 0)
1941 0 109 if ($Self->{'delete_defang_content'}) { }
1949 605 0 if (defined $Key)
1951 109 496 if ($CommentDefang)
1960 0 605 if $Self->{'Debug'}
2000 654 0 defined $AttrKey ? :
2004 0 654 if $Debug
2010 95 869 if (exists $Self->{'tags_to_callback'}{$lcTag})
2011 0 95 if $Debug
2019 0 654 if $Debug
2022 578 76 if (ref $Tags{$lcTag} eq 'HASH')
2029 0 654 if $Debug
2032 6 10 if ($Self->{'url_callback'} and $AttribRule and exists $UrlRules{$AttribRule})
2033 0 6 if $Debug
2035 0 6 unless defined pos $$HtmlR
2039 204 450 if ($lcAttrKey eq 'style')
2040 0 204 if $Debug
2045 0 0 if ($Self->{'attribs_callback'} and exists $Self->{'attribs_to_callback'}{$lcAttrKey})
2046 0 0 if $Debug
2049 0 0 if $DefangAttrib != 1
2067 20 634 unless ($AttributeHash{$lcAttr})
2068 0 20 if $Debug
2074 320 314 if ($Attr->[8] != 0)
2075 0 320 if ($Self->{'delete_defang_content'}) { }
2079 320 0 if $Self->{'allow_double_defang'} or not +($Attr->[0] || '') =~ /$Self->{'defang_re'}/
2087 634 0 if (defined $Attr->[4])
2105 28 1 if (defined $Attr->[4]) { }
2118 831 133 if ($DefangTag == 2 and my $TagOps = $Tags{$lcTag})
2122 0 964 if defined $DefangTagUrlOverride and $DefangTagUrlOverride == 1
2124 0 964 if defined $DefangTagAttrOverride and $DefangTagAttrOverride == 1
2137 0 654 if $Debug
2139 434 220 if ($DefangAttrib == 2 and $AttribRule) { }
214 12 elsif (not $AttribRule and $DefangAttrib != 0) { }
2141 0 434 if $Debug
2144 356 78 if (ref $Rule eq 'Regexp')
2145 312 44 $AttrValStripped =~ /$Rule/ ? :
2149 78 356 if (ref $Rule eq 'ARRAY')
2150 70 8 $AttrValStripped =~ /$Rule->[0]/i ? :
2157 0 654 if $Debug
2166 35 52 unless @$OpenedTags
2172 20 32 if (my $ImplicitTags = $ImplicitOpenTags{$LastTag})
2180 1 5 if not $IsEndTag and $Tag eq $lcTag
2182 5 0 unless $Self->{'quiet'}
2194 33 99 if ($BlockTags{$lcTag} and not $TableTags{$lcTag})
2200 3 0 unless $Quiet
2210 125 3 unless @$ClosedIntoBlockTags
2216 0 1 if $$HtmlR =~ m[\G(?=\s*
2222 3 0 if ($SpanCount < 3)
2225 3 0 unless $Self->{'quiet'}
2227 2 1 $POTD->[0] eq 'span' && $POTD->[1] eq $SpanAttrs ? :
2236 75 3 unless $NoBlockCheck
2240 52 26 if ($Self->{'mismatched_tags_to_fix'}{$lcTag})
2244 8 70 if ($AddOutput)
2248 75 3 unless $NoBlockCheck
2262 9 51 if (@$OpenedTags and $OpenedTags->[-1][0] ne $lcTag)
2266 57 3 unless $NoBlockCheck
2271 56 4 if ($IsTagToFix)
2275 4 52 unless $OpenedTagsCount->{$lcTag}
2281 52 6 if ($PreviousOpenedTag eq $lcTag)
2287 0 6 if (my $NestList = $MismatchedTagNest{$PreviousOpenedTag})
2288 0 0 if $NestList->{''} or $NestList->{$lcTag}
2292 6 0 unless $Quiet
2297 0 52 unless ($Found)
2304 0 52 if ($IsTagToFix and $Self->{'empty_tags_to_collapse'}{$lcTag})
2310 0 0 defined $RECache{$lcTag} ? :
2311 0 0 if ($$OutR =~ /$RE/cg) { }
0 0 elsif ($$OutR =~ /\G\s*(?:<|$)/cg and $LastTagPos > 0) { }
2323 52 4 if ($IsTagToFix)
2324 52 0 if ($lcTag eq $Self->{'opened_tags'}[-1][0]) { }
2331 39 17 if ($AddOutput)
2335 53 3 unless $NoBlockCheck
2350 30 0 unless $Quiet
2357 0 309 if ($Self->{'Debug'})
2359 0 0 if grep {$_ > 0;} values %$OpenedTagsCount
2389 6 648 unless defined $AttrVal
2400 1 135 if $V and $V > 127
2401 136 0 $V && $V < 1114111 && $V != 65535 && !($V > 55295 && $V < 57344) ? :
2405 0 13 unless $EntityToChar{lc $1}
2409 1 647 if $UnicodeEntity
2411 0 648 if $Self->{'Debug'}
2420 0 0 defined $1 && hex $1 < 1114111 && hex $1 != 65535 && !(hex $1 > 55295 && hex $1 < 57344) ? :
2438 0 0 unless ($Charset)
2447 0 0 unless defined $1 or defined $4
2452 0 0 if ($Attrs{'content'})
2453 0 0 $Attrs{'content'} =~ /charset\s*=\s*([^\s;'"`]+)[\s;'"`]*/i ? :
2459 0 0 $Charset ? :