line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------- |
2
|
|
|
|
|
|
|
# MKDoc::XML::Encode |
3
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------- |
4
|
|
|
|
|
|
|
# Author : Jean-Michel Hiver. |
5
|
|
|
|
|
|
|
# Copyright : (c) MKDoc Holdings Ltd, 2003 |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# This modules encodes XML entities & > < " and '. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# This module is distributed under the same license as Perl itself. |
10
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------- |
11
|
|
|
|
|
|
|
package MKDoc::XML::Encode; |
12
|
6
|
|
|
6
|
|
42184
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
201
|
|
13
|
6
|
|
|
6
|
|
32
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
1378
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our %XML_Encode = ( |
16
|
|
|
|
|
|
|
'&' => 'amp', |
17
|
|
|
|
|
|
|
'<' => 'lt', |
18
|
|
|
|
|
|
|
'>' => 'gt', |
19
|
|
|
|
|
|
|
'"' => 'quot', |
20
|
|
|
|
|
|
|
"'" => 'apos', |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $XML_Encode_Pattern = join ("|", keys %XML_Encode); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub process |
27
|
|
|
|
|
|
|
{ |
28
|
48
|
50
|
|
48
|
1
|
124
|
(@_ == 2) or warn "MKDoc::XML::Encode::process() should be called with two arguments"; |
29
|
|
|
|
|
|
|
|
30
|
48
|
|
|
|
|
66
|
my $class = shift; |
31
|
48
|
50
|
|
|
|
87
|
my $data = join '', map { (defined $_) ? $_ : '' } @_; |
|
48
|
|
|
|
|
164
|
|
32
|
48
|
|
|
|
|
301
|
$data =~ s/($XML_Encode_Pattern)/&$XML_Encode{$1};/go; |
33
|
48
|
|
|
|
|
278
|
return $data; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |