line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::Liberal::Remedy::UnclosedHTML; |
2
|
5
|
|
|
5
|
|
2320
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
111
|
|
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
1727
|
use HTML::Tagset (); |
|
5
|
|
|
|
|
4916
|
|
|
5
|
|
|
|
|
871
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my $ERROR_RX = do { |
7
|
|
|
|
|
|
|
# Exclude void elements |
8
|
|
|
|
|
|
|
my $pat = join '|', reverse sort grep { !$HTML::Tagset::emptyElement{$_} } |
9
|
|
|
|
|
|
|
keys %HTML::Tagset::isKnown; |
10
|
|
|
|
|
|
|
qr/^parser error : Opening and ending tag mismatch: ((?i:$pat)) line \d+ and (\S+)/ |
11
|
|
|
|
|
|
|
}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub apply { |
14
|
45
|
|
|
45
|
0
|
72
|
my $class = shift; |
15
|
45
|
|
|
|
|
79
|
my($driver, $error, $xml_ref) = @_; |
16
|
|
|
|
|
|
|
|
17
|
45
|
100
|
|
|
|
85
|
my ($unclosed, $detected) = $error->message =~ $ERROR_RX or return 0; |
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
|
|
79
|
my $index = $error->location; |
20
|
5
|
|
|
|
|
50
|
my $tail = substr $$xml_ref, $index, length($$xml_ref) - $index, ''; |
21
|
|
|
|
|
|
|
|
22
|
5
|
50
|
|
|
|
96
|
return 1 if $$xml_ref =~ s{( \Q$detected\E \s* > \z )}{$unclosed>$1$tail}xms; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
Carp::carp("Can't find incorrect close tag"); |
25
|
0
|
|
|
|
|
|
return 0; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |