Branch Coverage

blib/lib/HTML/HTML5/Parser/Charset/DecodeHandle.pm
Criterion Covered Total %
branch 36 344 10.4


line true false branch
31 0 0 if ($csdef->{'uri'}{$XML_AUTO_CHARSET} or $obj->{'charset'} eq $XML_AUTO_CHARSET) { }
0 0 elsif ($csdef->{'uri'}{$XML_CHARSET . 'utf-8'}) { }
0 0 elsif ($csdef->{'uri'}{$XML_CHARSET . 'utf-16'}) { }
36 0 0 if (read $obj->{'filehandle'}, $b, 256)
39 0 0 if (substr($b, 0, 1) eq '<') { }
0 0 elsif (substr($b, 0, 3) eq "\357\273\277") { }
0 0 elsif (substr($b, 0, 2) eq "\000<") { }
0 0 elsif (substr($b, 0, 2) eq "\376\377") { }
0 0 elsif (substr($b, 0, 2) eq "\377\376") { }
0 0 elsif (substr($b, 0, 2) eq "\000\000") { }
40 0 0 if (substr($b, 1, 1) eq '?') { }
0 0 elsif (substr($b, 1, 1) eq "\000") { }
41 0 0 if ($b =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)? encoding\s*=\s*["']([^"']*)/x) { }
46 0 0 if (not $csdef->{'ascii8'} or $csdef->{'bom_required'})
55 0 0 if (defined $csdef->{'no_bom_variant'})
59 0 0 if (substr($b, 2, 2) eq "?\000") { }
0 0 elsif (substr($b, 2, 2) eq "\000\000") { }
61 0 0 if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)? encoding\s*=\s*["']([^"']*)/x) { }
66 0 0 if (not $csdef->{'ascii16'} or $csdef->{'ascii16be'} or $csdef->{'bom_required'})
76 0 0 if (defined $csdef->{'no_bom_variant16le'})
81 0 0 if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)? encoding\s*=\s*["']([^"']*)/x) { }
86 0 0 if (not $csdef->{'ascii32'} or $csdef->{'ascii32endian1234'} or $csdef->{'ascii32endian2143'} or $csdef->{'ascii32endian3412'} or $csdef->{'bom_required'})
99 0 0 if (defined $csdef->{'no_bom_variant32endian4321'})
108 0 0 if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)? encoding\s*=\s*["']([^"']*)/x) { }
113 0 0 unless ($csdef->{'utf8_encoding_scheme'} and $csdef->{'bom_allowed'})
123 0 0 if (defined $csdef->{'no_bom_variant'})
127 0 0 if (substr($b, 2, 2) eq "\000?") { }
0 0 elsif (substr($b, 2, 2) eq "\000\000") { }
129 0 0 if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)? encoding\s*=\s*["']([^"']*)/x) { }
134 0 0 if (not $csdef->{'ascii16'} or $csdef->{'ascii16le'} or $csdef->{'bom_required'})
144 0 0 if (defined $csdef->{'no_bom_variant16be'})
149 0 0 if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)? encoding\s*=\s*["']([^"']*)/x) { }
154 0 0 if (not $csdef->{'ascii32'} or $csdef->{'ascii32endian1234'} or $csdef->{'ascii32endian2143'} or $csdef->{'ascii32endian4321'} or $csdef->{'bom_required'})
167 0 0 if (defined $csdef->{'no_bom_variant32endian3412'})
172 0 0 if (substr($b, 2, 2) eq "\000<") { }
0 0 elsif (substr($b, 2, 2) eq "\000\000") { }
176 0 0 if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)? encoding\s*=\s*["']([^"']*)/x) { }
181 0 0 if (not $csdef->{'ascii16'} or $csdef->{'ascii16le'} or not $csdef->{'bom_allowed'})
192 0 0 if (defined $csdef->{'no_bom_variant16be'})
199 0 0 if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)? encoding\s*=\s*["']([^"']*)/x) { }
204 0 0 if (not $csdef->{'ascii32'} or $csdef->{'ascii32endian1234'} or $csdef->{'ascii32endian2143'} or $csdef->{'ascii32endian4321'} or not $csdef->{'bom_allowed'})
218 0 0 if (defined $csdef->{'no_bom_variant32endian3412'})
228 0 0 if (substr($b, 2, 2) eq "<\000") { }
0 0 elsif (substr($b, 2, 2) eq "\000\000") { }
232 0 0 if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)? encoding\s*=\s*["']([^"']*)/x) { }
237 0 0 if (not $csdef->{'ascii16'} or $csdef->{'ascii16be'} or not $csdef->{'bom_allowed'})
248 0 0 if (defined $csdef->{'no_bom_variant16le'})
255 0 0 if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)? encoding\s*=\s*["']([^"']*)/x) { }
260 0 0 if (not $csdef->{'ascii32'} or $csdef->{'ascii32endian1234'} or $csdef->{'ascii32endian2143'} or $csdef->{'ascii32endian3412'} or not $csdef->{'bom_allowed'})
274 0 0 if (defined $csdef->{'no_bom_variant32endian4321'})
284 0 0 if (substr($b, 2, 2) eq "\000<") { }
0 0 elsif (substr($b, 2, 2) eq "<\000") { }
0 0 elsif (substr($b, 2, 2) eq "\376\377") { }
0 0 elsif (substr($b, 2, 2) eq "\377\376") { }
286 0 0 if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)? encoding\s*=\s*["']([^"']*)/x) { }
291 0 0 if (not $csdef->{'ascii32'} or $csdef->{'ascii32endian2143'} or $csdef->{'ascii32endian3412'} or $csdef->{'ascii32endian4321'} or $csdef->{'bom_required'})
304 0 0 if (defined $csdef->{'no_bom_variant32endian1234'})
309 0 0 if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)? encoding\s*=\s*["']([^"']*)/x) { }
314 0 0 if (not $csdef->{'ascii32'} or $csdef->{'ascii32endian1234'} or $csdef->{'ascii32endian3412'} or $csdef->{'ascii32endian4321'} or $csdef->{'bom_required'})
327 0 0 if (defined $csdef->{'no_bom_variant32endian2143'})
334 0 0 if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)? encoding\s*=\s*["']([^"']*)/x) { }
339 0 0 if (not $csdef->{'ascii32'} or $csdef->{'ascii32endian2143'} or $csdef->{'ascii32endian3412'} or $csdef->{'ascii32endian4321'} or $csdef->{'bom_required'})
354 0 0 if (defined $csdef->{'no_bom_variant32endian1234'})
361 0 0 if ($c =~ /^<\?xml\s+(?:version\s*=\s*["'][^"']*["']\s*)? encoding\s*=\s*["']([^"']*)/x) { }
366 0 0 if (not $csdef->{'ascii32'} or $csdef->{'ascii32endian1234'} or $csdef->{'ascii32endian3412'} or $csdef->{'ascii32endian4321'} or $csdef->{'bom_required'})
381 0 0 if (defined $csdef->{'no_bom_variant32endian2143'})
392 0 0 if (read $obj->{'filehandle'}, $b, 3)
393 0 0 if ($b eq "\357\273\277") { }
403 0 0 if (read $obj->{'filehandle'}, $b, 2) { }
404 0 0 if ($b eq "\376\377") { }
0 0 elsif ($b eq "\377\376") { }
423 0 0 if ($csdef->{'uri'}{$XML_CHARSET . 'iso-2022-jp'}) { }
0 0 elsif ($csdef->{'uri'}{$IANA_CHARSET . 'iso-2022-jp'}) { }
0 0 elsif (defined $csdef->{'perl_name'}[0]) { }
429 0 0 if (&Encode::find_encoding($obj->{'state_2440'}) and &Encode::find_encoding($obj->{'state_2442'}))
439 0 0 if (&Encode::find_encoding($obj->{'state_2440'}) and &Encode::find_encoding($obj->{'state_2442'}))
444 0 0 if ($csdef->{'uri'}{$XML_CHARSET . 'euc-jp'} or $csdef->{'uri'}{$IANA_CHARSET . 'euc-jp'}) { }
0 0 elsif ($csdef->{'uri'}{$XML_CHARSET . 'shift_jis'} or $csdef->{'uri'}{$IANA_CHARSET . 'shift_jis'}) { }
0 0 elsif ($csdef->{'is_block_safe'}) { }
448 0 0 if (&Encode::find_encoding($obj->{'perl_encoding_name'}))
456 0 0 if (&Encode::find_encoding($obj->{'perl_encoding_name'}))
462 0 0 if (&Encode::find_encoding($obj->{'perl_encoding_name'}))
477 0 0 if ($domain eq 'ietf') { }
0 0 elsif ($domain eq 'xml') { }
480 0 0 if ({'utf-8', 1, 'utf-16', 1, 'iso-10646-ucs-2', 1, 'iso-10646-ucs-4', 1, 'iso-8859-1', 1, 'iso-8859-2', 1, 'iso-8859-3', 1, 'iso-8859-4', 1, 'iso-8859-5', 1, 'iso-8859-6', 1, 'iso-8859-7', 1, 'iso-8859-8', 1, 'iso-8859-9', 1, 'iso-8859-10', 1, 'iso-8859-11', 1, 'iso-8859-13', 1, 'iso-8859-14', 1, 'iso-8859-15', 1, 'iso-8859-16', 1, 'iso-2022-jp', 1, 'shift_jis', 1, 'euc-jp', 1}->{$name})
508 0 0 if $HTML::HTML5::Parser::Charset::CharsetDef->{$uri}
519 0 0 if ($domain eq 'xml')
521 0 0 if defined $v
523 0 0 if (substr($uri, 0, length $XML_CHARSET) eq $XML_CHARSET)
530 0 0 if ($domain eq 'ietf')
532 0 0 if defined $v
534 0 0 if (substr($uri, 0, length $IANA_CHARSET) eq $IANA_CHARSET)
581 0 0 if ($self->{'pos'} < length ${$self->{'string'};}) { }
605 0 0 if (${$self->{'string'};} =~ /\G(?>$_[2])+/) { }
617 0 0 if $self->{'pos'} > 0
635 0 0 if ($l) { }
653 0 5340 if $length < 1
655 1227 4113 if (my $l = length(${$self->{'char_buffer'};}) - $self->{'char_buffer_pos'})
656 144 1083 if ($l >= $length) { }
675 2596 2600 if ($eof)
680 0 2600 if ($self->{'continue'}) { }
2598 2 elsif (512 > length $self->{'byte_buffer'}) { }
681 0 0 if ($self->{'filehandle'}->read($self->{'byte_buffer'}, 256, length $self->{'byte_buffer'})) { }
689 0 2598 if ($self->{'filehandle'}->read($self->{'byte_buffer'}, 256, length $self->{'byte_buffer'})) { }
697 2600 0 unless ($error)
698 711 1889 unless ($self->{'bom_checked'})
699 709 2 if (defined $self->{'bom_pattern'})
700 0 709 if ($self->{'byte_buffer'} =~ s/^$self->{'bom_pattern'}//)
707 0 0 unless $_[0] =~ /^Code point/
714 711 1889 if (length $string) { }
717 0 711 if (length $self->{'byte_buffer'})
721 0 1889 if (length $self->{'byte_buffer'}) { }
730 0 711 if ($error)
735 0 0 if ($self->{'category'} & 4) { }
0 0 elsif ($self->{'category'} & 2) { }
737 0 0 if ($r =~ /^[\x81-\x9F\xE0-\xFC]/) { }
0 0 elsif ($r =~ /^[\x80\xA0\xFD-\xFF]/) { }
738 0 0 if ($self->{'byte_buffer'} =~ s/(.)//s)
752 0 0 if ($r =~ /^[\xA1-\xFE]/) { }
0 0 elsif ($r eq "\217") { }
0 0 elsif ($r eq "\216") { }
0 0 elsif ($r eq "\240" or $r eq "\377") { }
753 0 0 if ($self->{'byte_buffer'} =~ s/^([\xA1-\xFE])//)
758 0 0 if ($self->{'byte_buffer'} =~ s/^([\xA1-\xFE][\xA1-\xFE]?)//)
760 0 0 if length $1 == 2
763 0 0 if ($self->{'byte_buffer'} =~ s/^([\xA1-\xFE])//)
772 0 0 if (defined $fallback) { }
0 0 elsif (exists $self->{'fallback'}{$r}) { }
791 0 0 if ($s eq "\r") { }
0 0 elsif ($s eq "\n") { }
795 0 0 if substr($_[1], $i - $count + 1, 1) eq "\n"
805 0 0 if ($count and substr(${$self->{'char_buffer'};}, -1, 1) eq "\r")
806 0 0 if (substr(${$self->{'char_buffer'};}, $i, 1) eq "\n")
813 0 0 if ($s eq "\r") { }
0 0 elsif ($s eq "\n") { }
817 0 0 if substr($_[1], $i + 1, 1) eq "\n"
827 0 0 $set_col ? :
834 0 0 defined $fallback ? :
846 883 1011 if ($s =~ /^(?>$_[2])+/) { }
209 802 elsif (length $s) { }
848 174 709 if ($rem_length)
849 3 171 if ($self->{'char_buffer_pos'} > $rem_length) { }
860 2 207 if ($self->{'char_buffer_pos'} > length $s) { }
874 0 0 if defined $v
877 0 0 if (defined $uri)
885 711 711 if (@_ > 1)
886 711 0 if ($_[1]) { }
895 1422 0 $_[0]{'onerror_set'} ? :
907 0 0 if @{$self->{'character_queue'};}
912 0 0 if ($self->{'continue'}) { }
0 0 elsif (512 > length $self->{'byte_buffer'}) { }
913 0 0 if ($self->{'filehandle'}->read($self->{'byte_buffer'}, 256, length $self->{'byte_buffer'})) { }
925 0 0 unless ($error)
926 0 0 if ($self->{'byte_buffer'} =~ s/^\x1B(\x24[\x40\x42]|\x28[\x42\x4A])//) { }
0 0 elsif ($self->{'state'} eq 'state_2842') { }
0 0 elsif ($self->{'state'} eq 'state_284A') { }
0 0 elsif ($self->{'state'} eq 'state_2442') { }
0 0 elsif ($self->{'state'} eq 'state_2440') { }
935 0 0 if ($self->{'byte_buffer'} =~ s/^([\x00-\x0D\x10-\x1A\x1C-\x7F]+)//) { }
939 0 0 if (length $self->{'byte_buffer'}) { }
946 0 0 if ($self->{'byte_buffer'} =~ s/^([\x00-\x0D\x10-\x1A\x1C-\x7F]+)//) { }
952 0 0 if (length $self->{'byte_buffer'}) { }
965 0 0 if (length $v) { }
969 0 0 if (length $self->{'byte_buffer'}) { }
982 0 0 if (length $v) { }
986 0 0 if (length $self->{'byte_buffer'}) { }
1000 0 0 if ($error)
1003 0 0 if ($self->{'state'} eq 'state_2442' || $self->{'state'} eq 'state_2440' and $r =~ /^[\x21-\x7E]/ and $self->{'byte_buffer'} =~ s/^([\x21-\x7E])//) { }
0 0 elsif ($r eq "\e" and $self->{'byte_buffer'} =~ s/^\(H//) { }
1030 0 0 unless defined $c
1044 0 0 if ($c =~ /^$_[2]/) { }
0 0 elsif (defined $c) { }