Commit 069fb85a authored by IKEDA Soji's avatar IKEDA Soji
Browse files

Additional fix for #841.

parent 544db3fe
......@@ -787,10 +787,11 @@ sub _compile_condition {
## available.
if (defined $index) {
$value =
sprintf 'do { my @h = $context->{message}->get_header(\'%s\'); $h[%s] }',
sprintf 'do { my @h = $context->{message}->get_header(\'%s\'); $h[%s] // \'\' }',
$field_name, $index;
} else {
$value = sprintf '[$context->{message}->get_header(\'%s\')]',
$value =
sprintf 'do { my @h = $context->{message}->get_header(\'%s\'); [@h || (\'\')]}',
$field_name;
}
$required_keys{message} = 1;
......@@ -906,8 +907,6 @@ sub _compile_condition_term {
if ($condition_key =~ /\A(is_owner|is_editor|is_subscriber)\z/) {
# Interpret '[listname]' as $that.
$args[0] = '$that' if $args[0] eq '$that->{name}';
} elsif ($condition_key eq 'match') {
return sprintf '(%s =~ %s)', $args[0], $args[1];
}
} elsif ($condition_key =~ /^customcondition::(\w+)$/) {
return sprintf 'do_verify_custom($that, %s, %s, %s)',
......@@ -1109,28 +1108,16 @@ sub do_match {
my $that = shift;
my $condition_key = shift;
my @args = @_;
unless ($args[1] =~ /^\/(.*)\/$/) {
$log->syslog('err', 'Match parameter %s is not a regexp', $args[1]);
return undef;
}
my $regexp = $1;
# Nothing can match an empty regexp.
return 0 unless length $regexp;
my $robot = (ref $that eq 'Sympa::List') ? $that->{'domain'} : $that;
my $reghost = Conf::get_robot_conf($robot, 'domain');
$reghost =~ s/\./\\./g;
# "[host]" as alias of "[domain]": Compat. < 6.2.32
$regexp =~ s/[[](?:domain|host)[]]/$reghost/g;
return 0 unless length $args[1];
# wrap matches with eval{} to avoid crash by malformed regexp.
my $r = 0;
if (ref($args[0])) {
if (ref $args[0] eq 'ARRAY') {
eval {
foreach my $arg (@{$args[0]}) {
if ($arg =~ /$regexp/i) {
if ($arg =~ /$args[1]/i) {
$r = 1;
last;
}
......@@ -1138,7 +1125,7 @@ sub do_match {
};
} else {
eval {
if ($args[0] =~ /$regexp/i) {
if ($args[0] =~ /$args[1]/i) {
$r = 1;
}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment