From 59414ce84e177a34d1327ba10b8c8e06d3d07d03 Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Tue, 17 Apr 2012 15:58:36 -0700 Subject: [PATCH] rip out safe support in Debbugs::Text --- Debbugs/Text.pm | 86 ++++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/Debbugs/Text.pm b/Debbugs/Text.pm index 3df0e63..5c5cff8 100644 --- a/Debbugs/Text.pm +++ b/Debbugs/Text.pm @@ -119,7 +119,7 @@ sub fill_in_template{ output => {type => HANDLE, optional => 1, }, - safe => {type => OBJECT, + safe => {type => OBJECT|UNDEF, optional => 1, }, hole_var => {type => HASHREF, @@ -154,41 +154,41 @@ sub fill_in_template{ die "Unable to find template $param{template} with language $param{language}"; } - if (defined $param{safe}) { - $safe = $param{safe}; - } - else { - print STDERR "Created new safe\n" if $DEBUG; - $safe = Safe->new() or die "Unable to create safe compartment"; - $safe->permit_only(':base_core',':base_loop',':base_mem', - qw(padsv padav padhv padany), - qw(rv2gv refgen srefgen ref), - qw(caller require entereval), - qw(gmtime time sprintf prtf), - qw(sort), - ); - $safe->share('*STDERR'); - $safe->share('%config'); - $hole->wrap(\&Debbugs::Text::include,$safe,'&include'); - my $root = $safe->root(); - # load variables into the safe - for my $key (keys %{$param{variables}||{}}) { - print STDERR "Loading $key\n" if $DEBUG; - if (ref($param{variables}{$key})) { - no strict 'refs'; - print STDERR $safe->root().'::'.$key,qq(\n) if $DEBUG; - *{"${root}::$key"} = $param{variables}{$key}; - } - else { - no strict 'refs'; - ${"${root}::$key"} = $param{variables}{$key}; - } - } - for my $key (keys %{exists $param{hole_var}?$param{hole_var}:{}}) { - print STDERR "Wraping $key as $param{hole_var}{$key}\n" if $DEBUG; - $hole->wrap($param{hole_var}{$key},$safe,$key); - } - } +# if (defined $param{safe}) { +# $safe = $param{safe}; +# } +# else { +# print STDERR "Created new safe\n" if $DEBUG; +# $safe = Safe->new() or die "Unable to create safe compartment"; +# $safe->permit_only(':base_core',':base_loop',':base_mem', +# qw(padsv padav padhv padany), +# qw(rv2gv refgen srefgen ref), +# qw(caller require entereval), +# qw(gmtime time sprintf prtf), +# qw(sort), +# ); +# $safe->share('*STDERR'); +# $safe->share('%config'); +# $hole->wrap(\&Debbugs::Text::include,$safe,'&include'); +# my $root = $safe->root(); +# # load variables into the safe +# for my $key (keys %{$param{variables}||{}}) { +# print STDERR "Loading $key\n" if $DEBUG; +# if (ref($param{variables}{$key})) { +# no strict 'refs'; +# print STDERR $safe->root().'::'.$key,qq(\n) if $DEBUG; +# *{"${root}::$key"} = $param{variables}{$key}; +# } +# else { +# no strict 'refs'; +# ${"${root}::$key"} = $param{variables}{$key}; +# } +# } +# for my $key (keys %{exists $param{hole_var}?$param{hole_var}:{}}) { +# print STDERR "Wraping $key as $param{hole_var}{$key}\n" if $DEBUG; +# $hole->wrap($param{hole_var}{$key},$safe,$key); +# } +# } $language = $param{language}; my $tt; if ($tt_type eq 'FILE' and @@ -213,7 +213,13 @@ sub fill_in_template{ if (not defined $tt) { die "Unable to create Text::Template for $tt_type:$tt_source"; } - my $ret = $tt->fill_in(SAFE => $safe, + my $ret = $tt->fill_in(#SAFE => $safe, + PACKAGE => 'DTT', + HASH => {%{$param{variables}//{}}, + %{$param{hole_var}//{}}, + include => \&Debbugs::Text::include, + config => \%config, + }, defined $param{output}?(OUTPUT=>$param{output}):(), ); if (not defined $ret) { @@ -223,10 +229,10 @@ sub fill_in_template{ if ($DEBUG) { no strict 'refs'; no warnings 'uninitialized'; - my $temp = $param{nosafe}?'main':$safe->{Root}; +# my $temp = $param{nosafe}?'main':$safe->{Root}; print STDERR "Variables for $param{template}\n"; - print STDERR "Safe $temp\n"; - print STDERR map {"$_: ".*{$_}."\n"} keys %{"${temp}::"}; +# print STDERR "Safe $temp\n"; +# print STDERR map {"$_: ".*{$_}."\n"} keys %{"${temp}::"}; } return $ret; -- 2.39.2