spamassassin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From felic...@apache.org
Subject svn commit: rev 43317 - spamassassin/trunk/lib/Mail/SpamAssassin
Date Sat, 04 Sep 2004 04:05:45 GMT
Author: felicity
Date: Fri Sep  3 21:05:44 2004
New Revision: 43317

Modified:
   spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
   spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
Log:
bug 3238: allow people to zero-pad the _SCORE_ tag if they want.  adds some backward compatibility
with 2.x, etc.

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm	(original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm	Fri Sep  3 21:05:44 2004
@@ -3067,7 +3067,11 @@
 
  _YESNOCAPS_       "YES"/"NO" for is/isn't spam
  _YESNO_           "Yes"/"No" for is/isn't spam
- _SCORE_           message score
+ _SCORE(PAD)_      message score, if PAD is included and is either spaces or
+                   zeroes, then pad scores with that many spaces or zeroes
+		   (default, none)  ie: _SCORE(0)_ makes 2.4 become 02.4,
+		   _SCORE(00)_ is 002.4.  12.3 would be 12.3 and 012.3
+		   respectively.
  _REQD_            message threshold
  _VERSION_         version (eg. 3.0.0 or 3.1.0-r26142-foo1)
  _SUBVERSION_      sub-version/code revision date (eg. 2004-01-10)

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm	(original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm	Fri Sep  3 21:05:44 2004
@@ -963,7 +963,7 @@
   my $self = shift;
   my $text = shift;
 
-  $text =~ s/_(\w+?)(?:\((.*?)\))?_/${\($self->_get_tag($1,$2 || ""))}/g;
+  $text =~ s/_(\w+?)(?:\((.*?)\))?_/${\($self->_get_tag($1,$2))}/g;
   return $text;
 }
 
@@ -1032,11 +1032,17 @@
 }
 
 sub _get_tag_value_for_score {
-  my $self   = shift;
-  
+  my ($self, $pad) = @_;
+
   my $score  = sprintf("%2.1f", $self->{score});
   my $rscore = $self->_get_tag_value_for_required_score();
-  
+
+  # padding
+  if (defined $pad && $pad =~ /^(0+| +)$/) {
+    my $count = length($1) + 3 - length($score);
+    $score = (substr($pad, 0, $count) . $score) if $count > 0;
+  }
+
   # Do some rounding tricks to avoid the 5.0!=5.0-phenomenon,
   # see <http://bugzilla.spamassassin.org/show_bug.cgi?id=2607>
   return $score if $self->{is_spam} or $score < $rscore;
@@ -1055,12 +1061,14 @@
 
   # tag data also comes from $self->{tag_data}->{TAG}
 
+  $tag = "" unless defined $tag; # can be "0", so use defined test
+
   %tags = ( YESNO     => sub {    $self->_get_tag_value_for_yesno() },
   
             YESNOCAPS => sub { uc $self->_get_tag_value_for_yesno() },
 
-            SCORE => sub { $self->_get_tag_value_for_score() },
-            HITS  => sub { $self->_get_tag_value_for_score() },
+            SCORE => sub { $self->_get_tag_value_for_score(shift) },
+            HITS  => sub { $self->_get_tag_value_for_score(shift) },
 
             REQD  => sub { $self->_get_tag_value_for_required_score() },
 

Mime
View raw message