Skip to content

Commit 069fb85

Browse files
committed
Additional fix for sympa-community#841.
1 parent 544db3f commit 069fb85

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

src/lib/Sympa/Scenario.pm

+7-20
Original file line numberDiff line numberDiff line change
@@ -787,10 +787,11 @@ sub _compile_condition {
787787
## available.
788788
if (defined $index) {
789789
$value =
790-
sprintf 'do { my @h = $context->{message}->get_header(\'%s\'); $h[%s] }',
790+
sprintf 'do { my @h = $context->{message}->get_header(\'%s\'); $h[%s] // \'\' }',
791791
$field_name, $index;
792792
} else {
793-
$value = sprintf '[$context->{message}->get_header(\'%s\')]',
793+
$value =
794+
sprintf 'do { my @h = $context->{message}->get_header(\'%s\'); [@h || (\'\')]}',
794795
$field_name;
795796
}
796797
$required_keys{message} = 1;
@@ -906,8 +907,6 @@ sub _compile_condition_term {
906907
if ($condition_key =~ /\A(is_owner|is_editor|is_subscriber)\z/) {
907908
# Interpret '[listname]' as $that.
908909
$args[0] = '$that' if $args[0] eq '$that->{name}';
909-
} elsif ($condition_key eq 'match') {
910-
return sprintf '(%s =~ %s)', $args[0], $args[1];
911910
}
912911
} elsif ($condition_key =~ /^customcondition::(\w+)$/) {
913912
return sprintf 'do_verify_custom($that, %s, %s, %s)',
@@ -1109,36 +1108,24 @@ sub do_match {
11091108
my $that = shift;
11101109
my $condition_key = shift;
11111110
my @args = @_;
1112-
unless ($args[1] =~ /^\/(.*)\/$/) {
1113-
$log->syslog('err', 'Match parameter %s is not a regexp', $args[1]);
1114-
return undef;
1115-
}
1116-
my $regexp = $1;
11171111

11181112
# Nothing can match an empty regexp.
1119-
return 0 unless length $regexp;
1120-
1121-
my $robot = (ref $that eq 'Sympa::List') ? $that->{'domain'} : $that;
1122-
1123-
my $reghost = Conf::get_robot_conf($robot, 'domain');
1124-
$reghost =~ s/\./\\./g;
1125-
# "[host]" as alias of "[domain]": Compat. < 6.2.32
1126-
$regexp =~ s/[[](?:domain|host)[]]/$reghost/g;
1113+
return 0 unless length $args[1];
11271114

11281115
# wrap matches with eval{} to avoid crash by malformed regexp.
11291116
my $r = 0;
1130-
if (ref($args[0])) {
1117+
if (ref $args[0] eq 'ARRAY') {
11311118
eval {
11321119
foreach my $arg (@{$args[0]}) {
1133-
if ($arg =~ /$regexp/i) {
1120+
if ($arg =~ /$args[1]/i) {
11341121
$r = 1;
11351122
last;
11361123
}
11371124
}
11381125
};
11391126
} else {
11401127
eval {
1141-
if ($args[0] =~ /$regexp/i) {
1128+
if ($args[0] =~ /$args[1]/i) {
11421129
$r = 1;
11431130
}
11441131
};

0 commit comments

Comments
 (0)