Better fix to avoid side effects and Jail warning (#2126 & #1717)

This commit is contained in:
Christophe Maudoux 2020-03-28 13:53:25 +01:00
parent fd337a2110
commit a7a2a425a5
3 changed files with 13 additions and 5 deletions

View File

@ -19,9 +19,10 @@ sub perlExpr {
$cpt->reval("BEGIN { 'warnings'->unimport; } $val");
my $err = join(
'',
grep( { $_ =~ /Undefined subroutine/ ? () : $_; } split( /\n/, $@, 0 ) )
grep( { $_ =~ /(?:Undefined subroutine|Devel::StackTrace)/ ? () : $_; }
split( /\n/, $@, 0 ) )
);
return $err ? ( 0, "__badExpression__: $err" ) : 1;
return $err ? ( -1, "__badExpression__: $err" ) : 1;
}
sub types {

View File

@ -25,8 +25,8 @@ sub perlExpr {
$Lemonldap::NG::Common::Safelib::functions );
$cpt->reval("BEGIN { 'warnings'->unimport; } $val");
my $err = join( '',
grep { $_ =~ /Undefined subroutine/ ? () : $_ } split( /\n/, $@ ) );
return $err ? ( 0, "__badExpression__: $err" ) : (1);
grep { $_ =~ /(?:Undefined subroutine|Devel::StackTrace)/ ? () : $_ } split( /\n/, $@ ) );
return $err ? ( -1, "__badExpression__: $err" ) : (1);
}
my $url = $RE{URI}{HTTP}{ -scheme => "https?" };

View File

@ -1207,7 +1207,14 @@ sub _execTest {
if ( $ref eq 'CODE' ) {
my ( $r, $m ) = ( $test->( $value, $conf, $attr ) );
if ($m) {
push @{ $self->{ ( $r ? 'warnings' : 'errors' ) } },
push @{
$self->{ (
$r > 0
? 'warnings'
: ( $r < 0 ? 'needConfirmation' : 'errors' )
)
}
},
{ message => "$key: $m" };
}
elsif ( !$r ) {