line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Stash::AutoEscape::Escaped::Base; |
2
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
3
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
80
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
9
|
use overload '""' => \&as_string; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
15
|
|
6
|
2
|
|
|
2
|
|
132
|
use overload "." => \&concat; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
12
|
|
7
|
2
|
|
|
2
|
|
98
|
use overload "fallback" => 1; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub ORIG () { 0 } |
10
|
|
|
|
|
|
|
sub FLAG () { 1 } |
11
|
|
|
|
|
|
|
sub ESCAPED() { 2 } |
12
|
|
|
|
|
|
|
sub CALLBACK() { 3 } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Flag is: |
15
|
|
|
|
|
|
|
# 0 or undef => Not escaped |
16
|
|
|
|
|
|
|
# 1 => Escaped by automaticaly |
17
|
|
|
|
|
|
|
# 2 => Escaped by automaticaly and value is changed! |
18
|
|
|
|
|
|
|
# 3 => Escaped by manually |
19
|
|
|
|
|
|
|
# 4 => Escaped by manually and value is changed! |
20
|
|
|
|
|
|
|
# other => user defined |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
31
|
|
|
31
|
0
|
39
|
my $class = shift; |
24
|
|
|
|
|
|
|
# $str, $flag, $escaped, $callback) = @_; |
25
|
31
|
|
|
|
|
133
|
my $self = bless [ @_ ], $class; |
26
|
31
|
|
|
|
|
241
|
$self |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new_as_escaped { |
30
|
2
|
|
|
2
|
0
|
27
|
my $class = shift; |
31
|
2
|
|
|
|
|
8
|
my $self = bless [ $_[0], "new_as_escaped", $_[0] ], $class; |
32
|
2
|
|
|
|
|
6
|
$self |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub flag { |
36
|
0
|
|
|
0
|
0
|
0
|
my ($self, $flag) = @_; |
37
|
0
|
0
|
|
|
|
0
|
if ($flag) { |
38
|
0
|
|
|
|
|
0
|
return $self->[FLAG] = $flag; |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
0
|
$self->[FLAG]; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
0
|
0
|
sub escape { |
44
|
|
|
|
|
|
|
# ABSTRACT METHOD |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub stop_callback { |
48
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
49
|
0
|
|
|
|
|
0
|
$self->[CALLBACK] = undef; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub escape_manually { |
53
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
54
|
0
|
|
|
|
|
0
|
my $escaped_string = $self->escape($self->[ORIG]); |
55
|
0
|
|
|
|
|
0
|
$self->[ESCAPED] = $escaped_string; |
56
|
0
|
0
|
|
|
|
0
|
$self->[FLAG] = ($self->[ORIG] eq $escaped_string) ? 3 : 4; |
57
|
0
|
|
|
|
|
0
|
return $self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub as_string { |
61
|
19
|
|
|
19
|
0
|
51
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# already escaped |
64
|
19
|
100
|
66
|
|
|
89
|
if ($self->[FLAG] && defined $self->[ESCAPED]) { |
65
|
9
|
50
|
|
|
|
21
|
$self->[CALLBACK]->($self) if (defined $self->[CALLBACK]); |
66
|
9
|
|
|
|
|
46
|
return $self->[ESCAPED]; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
10
|
|
|
|
|
60
|
my $escaped_string = $self->escape($self->[ORIG]); |
70
|
10
|
|
|
|
|
205
|
$self->[ESCAPED] = $escaped_string; |
71
|
10
|
50
|
|
|
|
32
|
$self->[FLAG] = ($self->[ORIG] eq $escaped_string) ? 1 : 2; |
72
|
10
|
50
|
|
|
|
30
|
$self->[CALLBACK]->($self) if (defined $self->[CALLBACK]); |
73
|
10
|
|
|
|
|
56
|
return $self->[ESCAPED]; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub concat { |
77
|
65
|
|
|
65
|
0
|
1427
|
my ( $self, $other, $reversed ) = @_; |
78
|
65
|
|
|
|
|
96
|
my $class = ref $self; |
79
|
65
|
50
|
100
|
|
|
424
|
if (defined $other && length $other && ref $other eq $class) { |
|
|
100
|
66
|
|
|
|
|
|
|
|
100
|
|
|
|
|
80
|
|
|
|
|
|
|
# warn "concat with EscapedHTML"; |
81
|
0
|
0
|
|
|
|
0
|
my $newval = ($reversed) ? $other->as_string . $self->as_string : $self->as_string . $other->as_string; |
82
|
0
|
|
|
|
|
0
|
return bless [ |
83
|
|
|
|
|
|
|
$newval, $self->[FLAG], $newval, $self->[CALLBACK] |
84
|
|
|
|
|
|
|
], $class; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
elsif (defined $other && length $other) { |
87
|
3
|
100
|
|
|
|
21
|
my $newval = ($reversed) ? $other . $self->as_string : $self->as_string . $other; |
88
|
3
|
|
|
|
|
26
|
return bless [ |
89
|
|
|
|
|
|
|
$newval, $self->[FLAG], $newval, $self->[CALLBACK] |
90
|
|
|
|
|
|
|
], $class; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
else { |
93
|
62
|
|
|
|
|
182
|
return $self; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|