]> git.donarmstrong.com Git - debbugs.git/commitdiff
rip out safe support in Debbugs::Text
authorDon Armstrong <don@donarmstrong.com>
Tue, 17 Apr 2012 22:58:36 +0000 (15:58 -0700)
committerDon Armstrong <don@donarmstrong.com>
Tue, 17 Apr 2012 22:58:36 +0000 (15:58 -0700)
Debbugs/Text.pm

index 3df0e6316d9ee38fa3e4fd1bd7e929a64165a637..5c5cff8b9bc6a82a4179b8276a68d05f9ce57a1a 100644 (file)
@@ -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;