line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Filter::Escapejs; |
2
|
2
|
|
|
2
|
|
783
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
45
|
|
3
|
2
|
|
|
2
|
|
8
|
use utf8; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
4
|
2
|
|
|
2
|
|
39
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
5
|
2
|
|
|
2
|
|
9
|
use parent 'DTL::Fast::Filter'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
11
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$DTL::Fast::FILTER_HANDLERS{escapejs} = __PACKAGE__; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $CHARMAP = { |
10
|
|
|
|
|
|
|
"\n" => '\n', |
11
|
|
|
|
|
|
|
"\r" => '\r', |
12
|
|
|
|
|
|
|
"\t" => '\t', |
13
|
|
|
|
|
|
|
"\0" => '\0', |
14
|
|
|
|
|
|
|
"\'" => '\'', |
15
|
|
|
|
|
|
|
"\"" => '\"', |
16
|
|
|
|
|
|
|
}; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#@Override |
19
|
|
|
|
|
|
|
sub filter |
20
|
|
|
|
|
|
|
{ |
21
|
1
|
|
|
1
|
0
|
2
|
shift; # self |
22
|
1
|
|
|
|
|
2
|
my $filter_manager = shift; # filter_manager |
23
|
1
|
|
|
|
|
2
|
my $value = shift; # value |
24
|
1
|
|
|
|
|
2
|
shift; # context |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
2
|
$filter_manager->{safe} = 1; |
27
|
1
|
|
|
|
|
13
|
$value =~ s/([\n\r\t\0'"])/$CHARMAP->{$1}/gs; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
4
|
return $value; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |