spamassassin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j.@apache.org
Subject svn commit: r380258 - /spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf.pm
Date Thu, 23 Feb 2006 22:43:47 GMT
Author: jm
Date: Thu Feb 23 14:43:42 2006
New Revision: 380258

URL: http://svn.apache.org/viewcvs?rev=380258&view=rev
Log:
bug 4795: improve validation of the 'score' option

Modified:
    spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf.pm

Modified: spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewcvs/spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf.pm?rev=380258&r1=380257&r2=380258&view=diff
==============================================================================
--- spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf.pm Thu Feb 23 14:43:42 2006
@@ -214,6 +214,11 @@
     code => sub {
       my ($self, $key, $value, $line) = @_;
       my($rule, @scores) = split(/\s+/, $value);
+      unless (defined $value && $value !~ /^$/ &&
+		(scalar @scores == 1 || scalar @scores == 4)) {
+	info("config: score: requires a symbolic rule name and 1 or 4 scores");
+	return $MISSING_REQUIRED_VALUE;
+      }
 
       # Figure out if we're doing relative scores, remove the parens if we are
       my $relative = 0;
@@ -221,18 +226,16 @@
         if (s/^\((-?\d+(?:\.\d+)?)\)$/$1/) {
 	  $relative = 1;
 	}
+	unless (/^-?\d+(?:\.\d+)?$/) {
+	  info("config: score: the non-numeric score ($_) is not valid, " .
+	    "a numeric score is required");
+	  return $INVALID_VALUE;
+	}
       }
 
       if ($relative && !exists $self->{scoreset}->[0]->{$rule}) {
-        my $msg = "config: relative score without previous setting in ".
-                    "configuration, skipping: $line";
-
-        if ($self->{lint_rules}) {
-          warn $msg."\n";
-        } else {
-          info($msg);
-        }
-        $self->{errors}++;
+        info("config: score: relative score without previous setting in " .
+	  "configuration");
         return $INVALID_VALUE;
       }
 
@@ -250,17 +253,6 @@
 
           $self->{scoreset}->[$index]->{$rule} = $score + 0.0;
         }
-      }
-      else {
-        my $msg = "config: score configuration option without actual scores, skipping: $line";
-
-        if ($self->{lint_rules}) {
-          warn $msg."\n";
-        } else {
-          info($msg);
-        }
-        $self->{errors}++;
-        return $MISSING_REQUIRED_VALUE;
       }
     }
   });



Mime
View raw message