line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package URI::Escape::JavaScript; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
87658
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
119
|
|
4
|
3
|
|
|
3
|
|
39
|
use 5.8.1; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
311
|
|
5
|
3
|
|
|
3
|
|
20
|
use warnings; |
|
3
|
|
|
|
|
23
|
|
|
3
|
|
|
|
|
159
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
7
|
3
|
|
|
3
|
|
3905
|
use Encode qw(encode FB_PERLQQ); |
|
3
|
|
|
|
|
46695
|
|
|
3
|
|
|
|
|
328
|
|
8
|
3
|
|
|
3
|
|
27
|
use base qw(Exporter); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
11105
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw(js_escape js_unescape); |
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw(escape unescape); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub escape { |
13
|
4
|
|
|
4
|
1
|
16
|
my $string = shift; |
14
|
4
|
|
|
|
|
24
|
$string =~ s{([\x00-\x29\x2C\x3A-\x40\x5B-\x5E\x60\x7B-\x7F])} |
15
|
12
|
|
|
|
|
49
|
{'%' . uc(unpack('H2', $1))}eg; # XXX JavaScript compatible |
16
|
4
|
|
|
14
|
|
27
|
$string = encode('ascii', $string, sub { sprintf '%%u%04X', $_[0] }); |
|
14
|
|
|
|
|
104
|
|
17
|
4
|
|
|
|
|
125
|
return $string; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub unescape { |
21
|
6
|
|
|
6
|
1
|
18
|
my $escaped = shift; |
22
|
6
|
|
|
|
|
23
|
$escaped =~ s/%u([0-9a-f]{4})/chr(hex($1))/eig; |
|
16
|
|
|
|
|
51
|
|
23
|
6
|
|
|
|
|
29
|
$escaped =~ s/%([0-9a-f]{2})/chr(hex($1))/eig; |
|
15
|
|
|
|
|
60
|
|
24
|
6
|
|
|
|
|
35
|
return $escaped; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
*js_escape = \&escape; |
28
|
|
|
|
|
|
|
*js_unescape = \&unescape; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
__END__ |