@@ -787,10 +787,11 @@ sub _compile_condition {
787
787
# # available.
788
788
if (defined $index ) {
789
789
$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] // \'\' }' ,
791
791
$field_name , $index ;
792
792
} else {
793
- $value = sprintf ' [$context->{message}->get_header(\' %s\' )]' ,
793
+ $value =
794
+ sprintf ' do { my @h = $context->{message}->get_header(\' %s\' ); [@h || (\'\' )]}' ,
794
795
$field_name ;
795
796
}
796
797
$required_keys {message } = 1;
@@ -906,8 +907,6 @@ sub _compile_condition_term {
906
907
if ($condition_key =~ / \A (is_owner|is_editor|is_subscriber)\z / ) {
907
908
# Interpret '[listname]' as $that.
908
909
$args [0] = ' $that' if $args [0] eq ' $that->{name}' ;
909
- } elsif ($condition_key eq ' match' ) {
910
- return sprintf ' (%s =~ %s)' , $args [0], $args [1];
911
910
}
912
911
} elsif ($condition_key =~ / ^customcondition::(\w +)$ / ) {
913
912
return sprintf ' do_verify_custom($that, %s, %s, %s)' ,
@@ -1109,36 +1108,24 @@ sub do_match {
1109
1108
my $that = shift ;
1110
1109
my $condition_key = shift ;
1111
1110
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 ;
1117
1111
1118
1112
# 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];
1127
1114
1128
1115
# wrap matches with eval{} to avoid crash by malformed regexp.
1129
1116
my $r = 0;
1130
- if (ref ( $args [0]) ) {
1117
+ if (ref $args [0] eq ' ARRAY ' ) {
1131
1118
eval {
1132
1119
foreach my $arg (@{$args [0]}) {
1133
- if ($arg =~ / $regexp /i ) {
1120
+ if ($arg =~ / $args [1] /i ) {
1134
1121
$r = 1;
1135
1122
last ;
1136
1123
}
1137
1124
}
1138
1125
};
1139
1126
} else {
1140
1127
eval {
1141
- if ($args [0] =~ / $regexp /i ) {
1128
+ if ($args [0] =~ / $args [1] /i ) {
1142
1129
$r = 1;
1143
1130
}
1144
1131
};
0 commit comments