You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by bi...@apache.org on 2018/03/12 17:49:59 UTC

svn commit: r1826582 - in /spamassassin: branches/3.4/lib/Mail/SpamAssassin/Conf.pm trunk/lib/Mail/SpamAssassin/Conf.pm

Author: billcole
Date: Mon Mar 12 17:49:59 2018
New Revision: 1826582

URL: http://svn.apache.org/viewvc?rev=1826582&view=rev
Log:
Update documentation of 'eval' rule method source, sanity-check method calls. Fixes Bug #7558

Modified:
    spamassassin/branches/3.4/lib/Mail/SpamAssassin/Conf.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm

Modified: spamassassin/branches/3.4/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.4/lib/Mail/SpamAssassin/Conf.pm?rev=1826582&r1=1826581&r2=1826582&view=diff
==============================================================================
--- spamassassin/branches/3.4/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/branches/3.4/lib/Mail/SpamAssassin/Conf.pm Mon Mar 12 17:49:59 2018
@@ -2825,8 +2825,8 @@ C<header SYMBOLIC_TEST_NAME header =~ /\
 =item header SYMBOLIC_TEST_NAME eval:name_of_eval_method([arguments])
 
 Define a header eval test.  C<name_of_eval_method> is the name of
-a method on the C<Mail::SpamAssassin::EvalTests> object.  C<arguments>
-are optional arguments to the function call.
+a method registered by a C<Mail::SpamAssassin::Plugin> object.
+C<arguments> are optional arguments to the function call.
 
 =item header SYMBOLIC_TEST_NAME eval:check_rbl('set', 'zone' [, 'sub-test'])
 
@@ -2939,7 +2939,10 @@ name.
       local ($1,$2);
       if ($value =~ /^(\S+)\s+(?:rbl)?eval:(.*)$/) {
         my ($rulename, $fn) = ($1, $2);
-
+        dbg("config: header eval rule name is $rulename function is $fn");
+        if ($fn !~ /^\w+(\(.*\))?$/) {
+          return $INVALID_VALUE;
+        }
         if ($fn =~ /^check_(?:rbl|dns)/) {
           $self->{parser}->add_test ($rulename, $fn, $TYPE_RBL_EVALS);
         }
@@ -2997,7 +3000,13 @@ Define a body eval test.  See above.
       my ($self, $key, $value, $line) = @_;
       local ($1,$2);
       if ($value =~ /^(\S+)\s+eval:(.*)$/) {
-        $self->{parser}->add_test ($1, $2, $TYPE_BODY_EVALS);
+        my ($rulename, $fn) = ($1, $2);
+        dbg("config: body eval rule name is $rulename function is $fn");
+
+        if ($fn !~ /^\w+(\(.*\))?$/) {
+          return $INVALID_VALUE;
+        }
+        $self->{parser}->add_test ($rulename, $fn, $TYPE_BODY_EVALS);
       }
       else {
 	my @values = split(/\s+/, $value, 2);

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm?rev=1826582&r1=1826581&r2=1826582&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm Mon Mar 12 17:49:59 2018
@@ -2824,8 +2824,8 @@ C<header SYMBOLIC_TEST_NAME header =~ /\
 =item header SYMBOLIC_TEST_NAME eval:name_of_eval_method([arguments])
 
 Define a header eval test.  C<name_of_eval_method> is the name of
-a method on the C<Mail::SpamAssassin::EvalTests> object.  C<arguments>
-are optional arguments to the function call.
+a method registered by a C<Mail::SpamAssassin::Plugin> object.
+C<arguments> are optional arguments to the function call.
 
 =item header SYMBOLIC_TEST_NAME eval:check_rbl('set', 'zone' [, 'sub-test'])
 
@@ -2938,7 +2938,10 @@ name.
       local ($1,$2);
       if ($value =~ /^(\S+)\s+(?:rbl)?eval:(.*)$/) {
         my ($rulename, $fn) = ($1, $2);
-
+        dbg("config: header eval rule name is $rulename function is $fn");
+        if ($fn !~ /^\w+(\(.*\))?$/) {
+          return $INVALID_VALUE;
+        }
         if ($fn =~ /^check_(?:rbl|dns)/) {
           $self->{parser}->add_test ($rulename, $fn, $TYPE_RBL_EVALS);
         }
@@ -2996,7 +2999,13 @@ Define a body eval test.  See above.
       my ($self, $key, $value, $line) = @_;
       local ($1,$2);
       if ($value =~ /^(\S+)\s+eval:(.*)$/) {
-        $self->{parser}->add_test ($1, $2, $TYPE_BODY_EVALS);
+        my ($rulename, $fn) = ($1, $2);
+        dbg("config: body eval rule name is $rulename function is $fn");
+
+        if ($fn !~ /^\w+(\(.*\))?$/) {
+          return $INVALID_VALUE;
+        }
+        $self->{parser}->add_test ($rulename, $fn, $TYPE_BODY_EVALS);
       }
       else {
 	my @values = split(/\s+/, $value, 2);