Skip to content

Commit

Permalink
Additional fixes to sympa-community#841.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikedas committed Jan 22, 2020
1 parent 182d6e7 commit 6f811ae
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/lib/Sympa/Scenario.pm
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,9 @@ sub _compile_condition_term {
return sprintf '(%s =~ %s)', $args[0], $args[1];
}
} elsif ($condition_key =~ /^customcondition::(\w+)$/) {
return sprintf 'do_verify_custom($that, %s, %s, %s)',
_compile_hashref($rule), $1, join ', ', @args;
my $mod = $1;
return sprintf 'do_verify_custom($that, %s, \'%s\', %s)',
_compile_hashref($rule), $mod, join ', ', @args;
} else {
$log->syslog('err', 'Syntax error: Unknown condition %s',
$condition_key);
Expand All @@ -926,8 +927,20 @@ sub _compile_hashref {
', ',
map {
my ($k, $v) = ($_, $hashref->{$_});
$v =~ s/([\\\'])/\\$1/g;
sprintf "%s => '%s'", $k, $v;
if (ref $v eq 'ARRAY') {
$v = join(
', ',
map {
my $i = $_;
$i =~ s/([\\\'])/\\$1/g;
"'$i'";
} @$v
);
sprintf '%s => [%s]', $k, $v;
} else {
$v =~ s/([\\\'])/\\$1/g;
sprintf "%s => '%s'", $k, $v;
}
} sort keys %$hashref
) . '}';
}
Expand Down

0 comments on commit 6f811ae

Please sign in to comment.