spamassassin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmcgr...@apache.org
Subject svn commit: r966355 - in /spamassassin/trunk: lib/Mail/SpamAssassin/PerMsgStatus.pm lib/Mail/SpamAssassin/Util.pm spamd/spamd.raw
Date Wed, 21 Jul 2010 18:51:13 GMT
Author: kmcgrail
Date: Wed Jul 21 18:51:13 2010
New Revision: 966355

URL: http://svn.apache.org/viewvc?rev=966355&view=rev
Log:
Bug 6419 patch commit to resolve rounding issue irregularity with spamd/spamc

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
    spamassassin/trunk/spamd/spamd.raw

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=966355&r1=966354&r2=966355&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Wed Jul 21 18:51:13 2010
@@ -1150,20 +1150,15 @@ sub _get_tag_value_for_yesno {
 }
 
 sub _get_tag_value_for_score {
-  my ($self, $pad) = @_;
+  #$pad parameter never used.  removed.
+  my ($self) = @_;
 
   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;
-  }
-
-  # bug 2607: Do some rounding tricks to avoid the 5.0!=5.0-phenomenon,
-  return $score if $self->{is_spam} or $score < $rscore;
-  return $rscore - 0.1;
+  #Change due to bug 6419 to use Util function for consistency with spamd
+  #and PerMessageStatus
+  return Mail::SpamAssassin::Util::get_tag_value_for_score($score, $rscore, $self->{is_spam});
 }
 
 sub _get_tag_value_for_required_score {

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm?rev=966355&r1=966354&r2=966355&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Util.pm Wed Jul 21 18:51:13 2010
@@ -1666,6 +1666,40 @@ sub fisher_yates_shuffle {
 
 ###########################################################################
 
+
+###########################################################################
+
+# bugs 6419 and 2607 relate to returning a score 1/10th lower than the
+# required score if the rounded to the 10th version of the score is equal
+# to the required score
+#
+# moved from PerMessageStatus.pm to here and modified to allow for a 
+# non-class version of the routine to be called from PerMessageStatus
+# and from spamd
+
+sub get_tag_value_for_score {
+  my ($score, $rscore, $is_spam) = @_;
+
+  #BASED ON _get_tag_value_for_score from PerMsgStatus.pm
+
+  $score  = sprintf("%2.1f", $score);
+  $rscore = sprintf("%2.1f", $rscore);
+
+  # if the email is spam, return the accurate score
+  # if the email is NOT spam and the score is less than the required score, 
+  #   then return the accurate score
+
+  return $score if $is_spam or $score < $rscore;
+
+  # if the email is NOT spam and $score = $rscore, return the $rscore - 0.1 
+  #   effectively flooring the value to the closest tenth
+
+  return $rscore - 0.1;
+}
+
+###########################################################################
+
+
 1;
 
 =back

Modified: spamassassin/trunk/spamd/spamd.raw
URL: http://svn.apache.org/viewvc/spamassassin/trunk/spamd/spamd.raw?rev=966355&r1=966354&r2=966355&view=diff
==============================================================================
--- spamassassin/trunk/spamd/spamd.raw (original)
+++ spamassassin/trunk/spamd/spamd.raw Wed Jul 21 18:51:13 2010
@@ -1575,8 +1575,8 @@ sub check {
   my $status = Mail::SpamAssassin::PerMsgStatus->new($spamtest, $mail);
   $status->check();
 
-  my $msg_score     = sprintf( "%.1f", $status->get_score );
-  my $msg_threshold = sprintf( "%.1f", $status->get_required_score );
+  my $msg_score     =  &Mail::SpamAssassin::Util::get_tag_value_for_score($status->get_score,
$status->get_required_score, $status->is_spam);
+  my $msg_threshold = sprintf( "%2.1f", $status->get_required_score );
 
   my $response_spam_status = "";
   my $was_it_spam;



Mime
View raw message