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