line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Template::Simple::Compiler::Safe; |
2
|
|
|
|
|
|
|
# Safe compiler. Totally experimental |
3
|
60
|
|
|
60
|
|
193
|
use strict; |
|
60
|
|
|
|
|
56
|
|
|
60
|
|
|
|
|
1304
|
|
4
|
60
|
|
|
60
|
|
173
|
use warnings; |
|
60
|
|
|
|
|
59
|
|
|
60
|
|
|
|
|
1173
|
|
5
|
|
|
|
|
|
|
|
6
|
60
|
|
|
60
|
|
187
|
use Text::Template::Simple::Dummy; |
|
60
|
|
|
|
|
58
|
|
|
60
|
|
|
|
|
10125
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.90'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub compile { |
11
|
2
|
|
|
2
|
1
|
2
|
shift; |
12
|
2
|
|
|
|
|
4
|
return __PACKAGE__->_object->reval(shift); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _object { |
16
|
2
|
|
|
2
|
|
4
|
my $class = shift; |
17
|
2
|
50
|
|
|
|
19
|
if ( $class->can('object') ) { |
18
|
0
|
|
|
|
|
0
|
my $safe = $class->object; |
19
|
0
|
0
|
0
|
|
|
0
|
if ( $safe && ref $safe ) { |
20
|
0
|
0
|
|
|
|
0
|
return $safe if eval { $safe->isa('Safe'); 'Safe-is-OK' }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
21
|
|
|
|
|
|
|
} |
22
|
0
|
0
|
|
|
|
0
|
my $end = $@ ? q{: }.$@ : q{.}; |
23
|
0
|
|
|
|
|
0
|
warn 'Safe object failed. Falling back to default' . $end . "\n"; |
24
|
|
|
|
|
|
|
} |
25
|
2
|
|
|
|
|
1160
|
require Safe; |
26
|
2
|
|
|
|
|
49887
|
my $safe = Safe->new('Text::Template::Simple::Dummy'); |
27
|
2
|
|
|
|
|
1509
|
$safe->permit( $class->_permit ); |
28
|
2
|
|
|
|
|
24
|
return $safe; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _permit { |
32
|
2
|
|
|
2
|
|
4
|
my $class = shift; |
33
|
2
|
50
|
|
|
|
23
|
return $class->permit if $class->can('permit'); |
34
|
2
|
|
|
|
|
9
|
return qw( :default require caller ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 NAME |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Text::Template::Simple::Compiler::Safe - Safe compiler |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 SYNOPSIS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Private module. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
This document describes version C<0.90> of C<Text::Template::Simple::Compiler::Safe> |
52
|
|
|
|
|
|
|
released on C<5 July 2016>. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Safe template compiler. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 METHODS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 compile STRING |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 AUTHOR |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Burak Gursoy <burak@cpan.org>. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 COPYRIGHT |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Copyright 2004 - 2016 Burak Gursoy. All rights reserved. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 LICENSE |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
71
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.24.0 or, |
72
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
73
|
|
|
|
|
|
|
=cut |