line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Template::Stash::AutoEscaping::Escaped::Base; |
2
|
3
|
|
|
3
|
|
2086
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
90
|
|
3
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
94
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
14
|
use overload '""' => \&as_string; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
24
|
|
6
|
3
|
|
|
3
|
|
279
|
use overload "." => \&concat; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
16
|
|
7
|
3
|
|
|
3
|
|
157
|
use overload "fallback" => 1; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
11
|
|
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 automatically |
17
|
|
|
|
|
|
|
# 2 => Escaped by automatically 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
|
13
|
|
|
13
|
1
|
24
|
my $class = shift; |
24
|
|
|
|
|
|
|
# $str, $flag, $escaped, $callback) = @_; |
25
|
13
|
|
|
|
|
72
|
my $self = bless [ @_ ], $class; |
26
|
13
|
|
|
|
|
301
|
$self |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new_as_escaped { |
30
|
2
|
|
|
2
|
1
|
67
|
my $class = shift; |
31
|
2
|
|
|
|
|
12
|
my $self = bless [ $_[0], "new_as_escaped", $_[0] ], $class; |
32
|
2
|
|
|
|
|
8
|
$self |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub flag { |
36
|
0
|
|
|
0
|
1
|
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
|
1
|
0
|
sub escape { |
44
|
|
|
|
|
|
|
# ABSTRACT METHOD |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub stop_callback { |
48
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
49
|
0
|
|
|
|
|
0
|
$self->[CALLBACK] = undef; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub escape_manually { |
53
|
0
|
|
|
0
|
1
|
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
|
20
|
|
|
20
|
1
|
4435
|
my $self = shift; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# already escaped |
64
|
20
|
100
|
66
|
|
|
112
|
if ($self->[FLAG] && defined $self->[ESCAPED]) { |
65
|
9
|
50
|
|
|
|
26
|
$self->[CALLBACK]->($self) if (defined $self->[CALLBACK]); |
66
|
9
|
|
|
|
|
75
|
return $self->[ESCAPED]; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
11
|
|
|
|
|
615
|
my $escaped_string = $self->escape($self->[ORIG]); |
70
|
11
|
|
|
|
|
26
|
$self->[ESCAPED] = $escaped_string; |
71
|
11
|
50
|
|
|
|
40
|
$self->[FLAG] = ($self->[ORIG] eq $escaped_string) ? 1 : 2; |
72
|
11
|
50
|
|
|
|
33
|
$self->[CALLBACK]->($self) if (defined $self->[CALLBACK]); |
73
|
11
|
|
|
|
|
70
|
return $self->[ESCAPED]; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub concat { |
77
|
65
|
|
|
65
|
1
|
1532
|
my ( $self, $other, $reversed ) = @_; |
78
|
65
|
|
|
|
|
102
|
my $class = ref $self; |
79
|
65
|
50
|
100
|
|
|
458
|
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
|
|
|
|
23
|
my $newval = ($reversed) ? $other . $self->as_string : $self->as_string . $other; |
88
|
3
|
|
|
|
|
31
|
return bless [ |
89
|
|
|
|
|
|
|
$newval, $self->[FLAG], $newval, $self->[CALLBACK] |
90
|
|
|
|
|
|
|
], $class; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
else { |
93
|
62
|
|
|
|
|
189
|
return $self; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=encoding utf8 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 NAME |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Template::Stash::AutoEscaping::Escaped::Base - escaped stuff base class |
104
|
|
|
|
|
|
|
L. Internal use. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SYNOPSIS |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
See L . |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 DESCRIPTION |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
For internal use. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 Methods |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 new |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Constructor. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 new_as_escaped |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Constructor. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 as_string |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Return the string. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 flag |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Flags |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head2 escape |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Abstract method. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 stop_callback |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Clear the callback. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 escape_manually |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Internal use. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 concat |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Stuff. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 CONSTANTS |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 ORIG |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
ORIG slot. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 FLAG |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
FLAG slot. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 ESCAPED |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Cache slot. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 CALLBACK |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Callback function. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 LICENSE |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
169
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 AUTHOR |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
mala Ecpan@ma.laE (original author of L) |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Shlomi Fish (L) added some enhancements and |
176
|
|
|
|
|
|
|
fixes, while disclaiming all rights, as part of his work for |
177
|
|
|
|
|
|
|
L and released the result as |
178
|
|
|
|
|
|
|
C . |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 SEE ALSO |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
L |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |