I'm trying to create a CGI application that allows users to Safely eval some types of Perl code. Of course I need the Safe module to only allow a small subset of opcodes that are considered safe and useful for this application.
Here's a test script I've been writing. It basically goes through and finds what opcodes $line needs to execute.
It ex
#!/usr/bin/perl
use Opcode;
use Safe;
my @names = Opcode::opset_to_ops(Opcode::full_opset);
my @neededops;
use CGI;
my $query=CGI::new();
print $query->header();
print "<HTML><BODY>";
foreach $name(@names)
{
my $cpt;
$cpt=undef;
$cpt=new Safe;
$cpt->share('$name');
my(@ops)=grep { $_ ne $name} @names;
$cpt->permit_only(@ops);
my $line=q{ print "Opcode: $name\n"; };
$cpt->reval($line);
push @neededops, $name if $@;
}
print "<HR>\n\n@neededops\n";
print "</BODY></HTML>";
It works fine from the command line but when I run it through a browser I get a "The document contains no data" dialog box. If I comment out $cpt->reval($line) this disappears. Any ideas why this might be happening?
Thanks a lot,
Banky