You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by do...@apache.org on 2005/12/09 03:26:47 UTC

svn commit: r355322 - in /spamassassin/branches/3.1/lib/Mail/SpamAssassin: Conf.pm Conf/Parser.pm

Author: dos
Date: Thu Dec  8 18:26:45 2005
New Revision: 355322

URL: http://svn.apache.org/viewcvs?rev=355322&view=rev
Log:
bug 4648: Illegal declaration of anonymous subroutine - Rules starting with digits fixed

Modified:
    spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf.pm
    spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf/Parser.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=355322&r1=355321&r2=355322&view=diff
==============================================================================
--- spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf.pm Thu Dec  8 18:26:45 2005
@@ -1743,7 +1743,7 @@
 If the C<[if-unset: STRING]> tag is present, then C<STRING> will
 be used if the header is not found in the mail message.
 
-Test names should not start with a number, and must contain only
+Test names must not start with a number, and must contain only
 alphanumerics and underscores.  It is suggested that lower-case characters
 not be used, and names have a length of no more than 22 characters,
 as an informal convention.  Dashes are not allowed.

Modified: spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf/Parser.pm
URL: http://svn.apache.org/viewcvs/spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf/Parser.pm?rev=355322&r1=355321&r2=355322&view=diff
==============================================================================
--- spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf/Parser.pm (original)
+++ spamassassin/branches/3.1/lib/Mail/SpamAssassin/Conf/Parser.pm Thu Dec  8 18:26:45 2005
@@ -533,13 +533,6 @@
   my ($k, $v);
 
   while ( ($k,$v) = each %{$conf->{tests}} ) {
-    if ($conf->{lint_rules}) {
-      if (length($k) > 50 && $k !~ /^__/ && $k !~ /^T_/) {
-        warn "config: warning: rule name '$k' is over 50 chars\n";
-        $conf->{errors}++;
-      }
-    }
-
     if ( ! exists $conf->{scores}->{$k} ) {
       # T_ rules (in a testing probationary period) get low, low scores
       my $set_score = ($k =~/^T_/) ? 0.01 : 1.0;
@@ -771,10 +764,30 @@
   my $conf = $self->{conf};
 
   # Don't allow invalid names ...
-  if ($name !~ /^\w+$/) {
-    warn "config: error: rule '$name' has invalid characters (not Alphanumeric + Underscore)\n";
+  if ($name !~ /^\D\w*$/) {
+    warn "config: error: rule '$name' has invalid characters ".
+	   "(not Alphanumeric + Underscore + starting with a non-digit)\n";
     $conf->{errors}++;
     return;
+  }
+
+  # Also set a hard limit for ALL rules (rule names longer than 242
+  # characters throw warnings).  Check this separately from the above
+  # pattern to avoid vague error messages.
+  if (length $name > 200) {
+    warn "config: error: rule '$name' is way too long ".
+	   "(recommended maximum length is 22 characters)\n";
+    $conf->{errors}++;
+    return;
+  }
+
+  # Warn about, but use, long rule names during --lint
+  if ($conf->{lint_rules}) {
+    if (length($name) > 50 && $name !~ /^__/ && $name !~ /^T_/) {
+      warn "config: warning: rule name '$name' is over 50 chars ".
+	     "(recommended maximum length is 22 characters)\n";
+      $conf->{errors}++;
+    }
   }
 
   # all of these rule types are regexps