line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::Liberal::Remedy::XHTMLEmptyTag; |
2
|
5
|
|
|
5
|
|
2107
|
use strict; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
105
|
|
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
19
|
use HTML::Tagset (); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
689
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my @ELEMENTS = sort keys %HTML::Tagset::emptyElement; |
7
|
|
|
|
|
|
|
my $ERROR_RX = do { |
8
|
|
|
|
|
|
|
my $pat = join '|', @ELEMENTS; |
9
|
|
|
|
|
|
|
qr/^parser error : Opening and ending tag mismatch: (?i:$pat)/; |
10
|
|
|
|
|
|
|
}; |
11
|
|
|
|
|
|
|
my $TAG_RX = do { |
12
|
|
|
|
|
|
|
my $pat = join '|', @ELEMENTS; |
13
|
|
|
|
|
|
|
qr{(<((?i:$pat)) (?: \s[^>]*)? ) (? (?! \s*\2\s*>))}x; |
14
|
|
|
|
|
|
|
}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# optimized to fix all errors in one apply() call |
17
|
|
|
|
|
|
|
sub apply { |
18
|
11
|
|
|
11
|
0
|
18
|
my $class = shift; |
19
|
11
|
|
|
|
|
23
|
my($driver, $error, $xml_ref) = @_; |
20
|
|
|
|
|
|
|
|
21
|
11
|
50
|
|
|
|
23
|
return if $error->message !~ $ERROR_RX; |
22
|
|
|
|
|
|
|
|
23
|
11
|
50
|
|
|
|
287
|
return 1 if $$xml_ref =~ s{$TAG_RX}{$1 /}g; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
Carp::carp("Can't find XHTML empty-element tags, error was: ", |
26
|
|
|
|
|
|
|
$error->summary); |
27
|
0
|
|
|
|
|
|
return 0; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |