line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package TX::Escape; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23430
|
use 5.008008; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
38
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
6
|
1
|
|
|
1
|
|
5
|
use Exporter 'import'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
489
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK=qw(html_esc url_esc url_unesc); |
9
|
|
|
|
|
|
|
our %EXPORT_TAGS=(all=>[@EXPORT_OK]); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION='0.01'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
my %h=( |
15
|
|
|
|
|
|
|
'"' => '"', |
16
|
|
|
|
|
|
|
'<' => '<', |
17
|
|
|
|
|
|
|
'>' => '>', |
18
|
|
|
|
|
|
|
'&' => '&', |
19
|
|
|
|
|
|
|
' ' => ' ', |
20
|
|
|
|
|
|
|
"\n" => ' ', |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
sub html_esc ($;$) { |
23
|
2
|
|
|
2
|
0
|
5
|
my ($s, $esc_space)=@_; |
24
|
2
|
50
|
|
|
|
10
|
return '' unless defined $s; |
25
|
2
|
100
|
|
|
|
6
|
if( $esc_space ) { |
26
|
1
|
|
|
|
|
6
|
$s=~s/([<>"& \n])/$h{$1}/ge; |
|
7
|
|
|
|
|
26
|
|
27
|
|
|
|
|
|
|
} else { |
28
|
1
|
|
|
|
|
5
|
$s=~s/([<>"&])/$h{$1}/ge; |
|
4
|
|
|
|
|
18
|
|
29
|
|
|
|
|
|
|
} |
30
|
2
|
|
|
|
|
11
|
return $s; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub url_esc ($) { |
35
|
1
|
|
|
1
|
0
|
185
|
my $v=shift; |
36
|
1
|
50
|
|
|
|
6
|
return '' unless defined $v; |
37
|
1
|
|
|
|
|
10
|
$v =~ s{([^A-Za-z0-9\-_.!~*'()/])}{sprintf("%%%02X",ord($1))}eg; |
|
184
|
|
|
|
|
534
|
|
38
|
1
|
|
|
|
|
12
|
return $v; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub url_unesc ($) { |
42
|
1
|
|
|
1
|
0
|
3
|
my $v=shift; |
43
|
1
|
50
|
|
|
|
5
|
return '' unless defined $v; |
44
|
1
|
50
|
|
|
|
12
|
$v =~ s/%([0-9a-f]{2})|\+/defined $1 ? pack('H2', $1) : ' '/egi; |
|
184
|
|
|
|
|
730
|
|
45
|
1
|
|
|
|
|
6
|
return $v; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
__END__ |