line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Template::Compiled::Plugin::XMLEscape; |
2
|
1
|
|
|
1
|
|
1132
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
4
|
1
|
|
|
1
|
|
3
|
use Carp qw(croak carp); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
5
|
1
|
|
|
1
|
|
4
|
use HTML::Template::Compiled; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
6
|
|
|
|
|
|
|
HTML::Template::Compiled->register(__PACKAGE__); |
7
|
|
|
|
|
|
|
our $VERSION = '1.002_001'; # TRIAL VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub register { |
10
|
1
|
|
|
1
|
1
|
1
|
my ($class) = @_; |
11
|
1
|
|
|
|
|
4
|
my %plugs = ( |
12
|
|
|
|
|
|
|
escape => { |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
XML => \&escape_xml, |
15
|
|
|
|
|
|
|
XML_ATTR => 'HTML::Template::Compiled::Plugin::XMLEscape::escape_xml_attr', |
16
|
|
|
|
|
|
|
}, |
17
|
|
|
|
|
|
|
); |
18
|
1
|
|
|
|
|
2
|
return \%plugs; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub escape_xml { |
22
|
2
|
50
|
|
2
|
1
|
10
|
defined( my $escaped = $_[0] ) or return; |
23
|
2
|
|
|
|
|
4
|
$escaped =~ s/&/&/g; |
24
|
2
|
|
|
|
|
6
|
$escaped =~ s/</g; |
25
|
2
|
|
|
|
|
4
|
$escaped =~ s/>/>/g; |
26
|
2
|
|
|
|
|
3
|
$escaped =~ s/"/"/g; |
27
|
2
|
|
|
|
|
2
|
$escaped =~ s/'/'/g; |
28
|
2
|
|
|
|
|
30
|
return $escaped; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub escape_xml_attr { |
32
|
2
|
50
|
|
2
|
1
|
6
|
defined( my $escaped = $_[0] ) or return; |
33
|
2
|
|
|
|
|
2
|
$escaped =~ s/&/&/g; |
34
|
2
|
|
|
|
|
5
|
$escaped =~ s/</g; |
35
|
2
|
|
|
|
|
4
|
$escaped =~ s/>/>/g; |
36
|
2
|
|
|
|
|
3
|
$escaped =~ s/"/"/g; |
37
|
2
|
|
|
|
|
2
|
$escaped =~ s/'/'/g; |
38
|
2
|
|
|
|
|
44
|
return $escaped; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |