line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Template::Simple::Compiler::Safe; |
2
|
|
|
|
|
|
|
# Safe compiler. Totally experimental |
3
|
62
|
|
|
62
|
|
379
|
use strict; |
|
62
|
|
|
|
|
130
|
|
|
62
|
|
|
|
|
8234
|
|
4
|
62
|
|
|
62
|
|
8353
|
use warnings; |
|
62
|
|
|
|
|
157
|
|
|
62
|
|
|
|
|
1738
|
|
5
|
|
|
|
|
|
|
|
6
|
62
|
|
|
62
|
|
336
|
use Text::Template::Simple::Dummy; |
|
62
|
|
|
|
|
117
|
|
|
62
|
|
|
|
|
18987
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.86'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub compile { |
11
|
2
|
|
|
2
|
1
|
3
|
shift; |
12
|
2
|
|
|
|
|
8
|
return __PACKAGE__->_object->reval(shift); |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub _object { |
16
|
2
|
|
|
2
|
|
10
|
my $class = shift; |
17
|
2
|
50
|
|
|
|
28
|
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
|
|
|
|
|
3449
|
require Safe; |
26
|
2
|
|
|
|
|
779956
|
my $safe = Safe->new('Text::Template::Simple::Dummy'); |
27
|
2
|
|
|
|
|
2767
|
$safe->permit( $class->_permit ); |
28
|
2
|
|
|
|
|
36
|
return $safe; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _permit { |
32
|
2
|
|
|
2
|
|
6
|
my $class = shift; |
33
|
2
|
50
|
|
|
|
29
|
return $class->permit if $class->can('permit'); |
34
|
2
|
|
|
|
|
14
|
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.86> of C<Text::Template::Simple::Compiler::Safe> |
52
|
|
|
|
|
|
|
released on C<5 March 2012>. |
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 - 2012 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.12.3 or, |
72
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |