line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::MicroMason::SafeServerPages; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
324
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my %block_types = ( |
8
|
|
|
|
|
|
|
'' => 'perl', # <% perl statements %> |
9
|
|
|
|
|
|
|
'=' => 'expr', # <%= perl expression (HTML escaped) %> |
10
|
|
|
|
|
|
|
'raw=' => 'expr', # <%= perl expression (raw) %> |
11
|
|
|
|
|
|
|
'--' => 'doc', # <%-- this text will not appear in the output --%> |
12
|
|
|
|
|
|
|
'&' => 'file', # <%& filename argument %> |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $re_eol = "(?:\\r?\\n|\\r|\\z)"; |
16
|
|
|
|
|
|
|
my $re_tag = "args|cleanup|doc|expr|file|init|once|perl|text"; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub lex_token { |
19
|
|
|
|
|
|
|
# Blocks in <%word> ... %word> tags. |
20
|
0
|
0
|
|
0
|
0
|
|
/\G <% ($re_tag) \s*> (.*?) <\/% \1 \s*> $re_eol? /xcogs ? ( $1 => $2 ) : |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Blocks in <% ... %> tags. |
23
|
|
|
|
|
|
|
/\G <% ((?:(?:raw)?=|&)?) (.*?) %> /gcxs ? ( $block_types{$1} => ($1 eq '=') ? "encode_entities(do { $2 }, '<>&\"\\'')" : $2 ) : |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Blocks in <%-- ... --%> tags. |
26
|
|
|
|
|
|
|
/\G <% -- (.*?) -- %> /gcxs ? ( 'doc' => $1 ) : |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Things that don't match the above. |
29
|
|
|
|
|
|
|
/\G ( (?: [^<] | <(?!\/?%) )+ ) /gcxs ? ( 'text' => $1 ) : |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Lexer error. |
32
|
|
|
|
|
|
|
() |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub assemble { |
37
|
0
|
|
|
0
|
0
|
|
my ($self, @tokens) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $perl_code = $self->NEXT('assemble', @tokens); |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return "do { use HTML::Entities; $perl_code };"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
__END__ |