line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DTL::Fast::Tag::Ssi; |
2
|
2
|
|
|
2
|
|
1332
|
use strict; use utf8; use warnings FATAL => 'all'; |
|
2
|
|
|
2
|
|
4
|
|
|
2
|
|
|
2
|
|
50
|
|
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
50
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
89
|
|
3
|
2
|
|
|
2
|
|
10
|
use parent 'DTL::Fast::Tag::Simple'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$DTL::Fast::TAG_HANDLERS{'ssi'} = __PACKAGE__; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
132
|
use DTL::Fast::Expression; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
884
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#@Override |
10
|
|
|
|
|
|
|
sub parse_parameters |
11
|
|
|
|
|
|
|
{ |
12
|
2
|
|
|
2
|
0
|
3
|
my $self = shift; |
13
|
2
|
50
|
|
|
|
23
|
if( $self->{'parameter'} =~ /^\s*(.+?)(?:\s*(parsed))?\s*$/ ) |
14
|
|
|
|
|
|
|
{ |
15
|
2
|
|
|
|
|
14
|
@{$self}{'template', 'parsed'} = ( |
|
2
|
|
|
|
|
7
|
|
16
|
|
|
|
|
|
|
DTL::Fast::Variable->new($1) |
17
|
|
|
|
|
|
|
, $2 |
18
|
|
|
|
|
|
|
); |
19
|
2
|
|
|
|
|
12
|
warn $self->get_parse_warning('`ssi` tag is now depricated and will be removed in future versions. Please, use `include` tag'); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
else |
22
|
|
|
|
|
|
|
{ |
23
|
0
|
|
|
|
|
0
|
die $self->get_parse_error("can't parse parameter: $self->{'parameter'}"); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
|
|
|
7
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#@Override |
30
|
|
|
|
|
|
|
# @todo: recursion protection |
31
|
|
|
|
|
|
|
sub render |
32
|
|
|
|
|
|
|
{ |
33
|
2
|
|
|
2
|
0
|
4
|
my ($self, $context, $result) = @_; |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
5
|
my $ssi_dirs = $context->{'ns'}->[-1]->{'_dtl_ssi_dirs'}; |
36
|
|
|
|
|
|
|
|
37
|
2
|
50
|
33
|
|
|
18
|
if( |
|
|
|
50
|
|
|
|
|
38
|
|
|
|
|
|
|
defined $ssi_dirs |
39
|
|
|
|
|
|
|
and ref $ssi_dirs eq 'ARRAY' |
40
|
|
|
|
|
|
|
and scalar @$ssi_dirs |
41
|
|
|
|
|
|
|
) |
42
|
|
|
|
|
|
|
{ |
43
|
2
|
|
|
|
|
8
|
my $template_path = $self->{'template'}->render($context); |
44
|
|
|
|
|
|
|
|
45
|
2
|
|
|
|
|
8
|
my $allowed = 0; |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
|
|
4
|
foreach my $allowed_dir (@$ssi_dirs) |
48
|
|
|
|
|
|
|
{ |
49
|
2
|
50
|
|
|
|
25
|
if( $template_path =~ /^\Q$allowed_dir\E/s ) |
50
|
|
|
|
|
|
|
{ |
51
|
2
|
|
|
|
|
3
|
$allowed = 1; |
52
|
2
|
|
|
|
|
5
|
last; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
2
|
50
|
|
|
|
5
|
if( $allowed ) |
57
|
|
|
|
|
|
|
{ |
58
|
2
|
|
|
|
|
67
|
$result = DTL::Fast::__read_file($template_path); |
59
|
|
|
|
|
|
|
|
60
|
2
|
100
|
|
|
|
8
|
if( $self->{'parsed'} ) |
61
|
|
|
|
|
|
|
{ |
62
|
1
|
|
|
|
|
6
|
$result = DTL::Fast::Template->new($result)->render($context); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
else |
66
|
|
|
|
|
|
|
{ |
67
|
0
|
|
0
|
|
|
0
|
die $self-get_render_error( |
68
|
|
|
|
|
|
|
$context, |
69
|
|
|
|
|
|
|
sprintf( |
70
|
|
|
|
|
|
|
"File %s is not in one of ssi_dirs:\n\t%s" |
71
|
|
|
|
|
|
|
, $template_path // 'undef' |
72
|
|
|
|
|
|
|
, join( "\n\t", @$ssi_dirs ) |
73
|
|
|
|
|
|
|
) |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
else |
78
|
|
|
|
|
|
|
{ |
79
|
0
|
|
|
|
|
0
|
die $self->get_render_error($context, 'in order to use ssi tag, you must provide ssi_dirs argument to the constructor'); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
2
|
|
|
|
|
51
|
return $result; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
1; |