@@ -678,10 +678,10 @@ sub _compile_condition {
678
678
}
679
679
} elsif ($value =~ / \[ custom_vars\-\> ([\w\- ]+)\] /i ) {
680
680
# Custom vars
681
- $value = sprintf ' $context->{custom_vars}{%1 }' , $1 ;
681
+ $value = sprintf ' $context->{custom_vars}{\' %s \' }' , $1 ;
682
682
} elsif ($value =~ / \[ family\-\> ([\w\- ]+)\] /i ) {
683
683
# Family vars
684
- $value = sprintf ' $context->{family}{%s }' , $1 ;
684
+ $value = sprintf ' $context->{family}{\' %s \' }' , $1 ;
685
685
} elsif ($value =~ / \[ conf\-\> ([\w\- ]+)\] /i ) {
686
686
# Config param
687
687
my $conf_key = $1 ;
@@ -725,7 +725,7 @@ sub _compile_condition {
725
725
if ( exists $pinfo -> {$canon_param }
726
726
and ref $pinfo -> {$canon_param }{format } ne ' HASH'
727
727
and $pinfo -> {$canon_param }{occurrence } !~ / n$ / ) {
728
- $value = sprintf ' $that->{admin}{%s }' , $canon_param ;
728
+ $value = sprintf ' $that->{admin}{\' %s \' }' , $canon_param ;
729
729
} else {
730
730
$log -> syslog(' err' ,
731
731
' Unknown list parameter %s in rule %s' ,
@@ -741,19 +741,19 @@ sub _compile_condition {
741
741
my $key = $1 ;
742
742
$value =
743
743
sprintf
744
- ' ($context->{user} || Sympa::User->new($context->{sender}))->{%s }' ,
744
+ ' ($context->{user} || Sympa::User->new($context->{sender}))->{\' %s \' }' ,
745
745
$key ;
746
746
} elsif ($value =~ / \[ user_attributes\-\> ([\w\- ]+)\] /i ) {
747
747
my $key = $1 ;
748
748
$value =
749
749
sprintf
750
- ' ($context->{user} || Sympa::User->new($context->{sender}))->{attributes}{%s }' ,
750
+ ' ($context->{user} || Sympa::User->new($context->{sender}))->{attributes}{\' %s \' }' ,
751
751
$key ;
752
752
} elsif ($value =~ / \[ subscriber\-\> ([\w\- ]+)\] /i ) {
753
753
my $key = $1 ;
754
754
$value =
755
755
sprintf
756
- ' ($context->{subscriber} || $that->get_list_memner($context->{sender}) || {})->{%s }' ,
756
+ ' ($context->{subscriber} || $that->get_list_memner($context->{sender}) || {})->{\' %s \' }' ,
757
757
$key ;
758
758
} elsif ($value =~
759
759
/ \[ (msg_header|header)\-\> ([\w\- ]+)\] (?:\[ ([-+]?\d +)\] )?/i ) {
@@ -907,8 +907,9 @@ sub _compile_condition_term {
907
907
return sprintf ' (%s =~ %s)' , $args [0], $args [1];
908
908
}
909
909
} elsif ($condition_key =~ / ^customcondition::(\w +)$ / ) {
910
- return sprintf ' do_verify_custom($that, %s, %s, %s)' ,
911
- _compile_hashref($rule ), $1 , join ' , ' , @args ;
910
+ my $mod = $1 ;
911
+ return sprintf ' do_verify_custom($that, %s, \' %s\' , %s)' ,
912
+ _compile_hashref($rule ), $mod , join ' , ' , @args ;
912
913
} else {
913
914
$log -> syslog(' err' , ' Syntax error: Unknown condition %s' ,
914
915
$condition_key );
@@ -926,8 +927,20 @@ sub _compile_hashref {
926
927
' , ' ,
927
928
map {
928
929
my ($k , $v ) = ($_ , $hashref -> {$_ });
929
- $v =~ s / ([\\\' ])/ \\ $1 / g ;
930
- sprintf " %s => '%s '" , $k , $v ;
930
+ if (ref $v eq ' ARRAY' ) {
931
+ $v = join (
932
+ ' , ' ,
933
+ map {
934
+ my $i = $_ ;
935
+ $i =~ s / ([\\\' ])/ \\ $1 / g ;
936
+ " '$i '" ;
937
+ } @$v
938
+ );
939
+ sprintf ' %s => [%s]' , $k , $v ;
940
+ } else {
941
+ $v =~ s / ([\\\' ])/ \\ $1 / g ;
942
+ sprintf " %s => '%s '" , $k , $v ;
943
+ }
931
944
} sort keys %$hashref
932
945
) . ' }' ;
933
946
}
0 commit comments