Subject: | strange behaviour with (?{ CODE }) in regex if CODE uses a restricted OP |
Hi,
Trying to use a very restricted safe compartment for evaluating
distrusted substitutions, but it misbehaves when (?{..}) is in the
regex. Consider the following example:
-------------------------------
use Safe;
my $re = q,s/(?{ $f=1 })a/b/,;
my $s = Safe->new;
$s->permit_only(qw(subst padany lineseq const rv2sv pushmark list
leaveeval concat));
$_='a';
$s->reval($re);
print "Lives\n";
die $@ if $@;
--------------------------------
$ perl test.pl
$ echo $?
0
$
Note no "Lives" is printed. It seems the script exit(0)s at the reval call.
Permitting sassign (scalar assignment) makes it run, but I'd like to
have this restricted.
Replacing $f=1 with simple 'warn' makes it run only if 'warn' is in the
permitted OPs, otherwise it exit(0)s again.
Problem also reproducible with Safe 2.12 (from Perl 5.10.0 core).
Thanks for considering,
Damyan