You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by gb...@apache.org on 2023/05/04 16:14:33 UTC
svn commit: r1909608 - /spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/TxRep.pm
Author: gbechis
Date: Thu May 4 16:14:33 2023
New Revision: 1909608
URL: http://svn.apache.org/viewvc?rev=1909608&view=rev
Log:
do not consider messages with delta of the opposite sign of the score
and of the old txrep score
bz #7943
Modified:
spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/TxRep.pm
Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/TxRep.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/TxRep.pm?rev=1909608&r1=1909607&r2=1909608&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/TxRep.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/TxRep.pm Thu May 4 16:14:33 2023
@@ -1494,8 +1494,23 @@ sub check_reputation {
$pms->set_tag('TXREP'.$tag_id, sprintf("%2.1f", $delta));
} elsif (defined $self->total()) {
#Bug 7164 - $msgscore undefined
- if (defined $msgscore) {
- $delta = ($self->total() + $msgscore) / (1 + $self->count()) - $msgscore;
+ # in some cases we can have negative number
+ # even if both total and $msgscore are positive numbers
+ my $deltacheck;
+ my $skipmsgscore = 0;
+ if(defined $msgscore) {
+ $deltacheck = ($self->total() + $msgscore) / (1 + $self->count()) - $msgscore;
+ if(($self->total() > 0) && ($msgscore > 0) && ($deltacheck < 0)) {
+ $skipmsgscore = 1;
+ } elsif(($self->total() < 0) && ($msgscore < 0) && ($deltacheck > 0)) {
+ $skipmsgscore = 1;
+ }
+ }
+ if($skipmsgscore) {
+ dbg("TxRep: skipping msg score $msgscore when calculating delta");
+ }
+ if (defined $msgscore and not $skipmsgscore) {
+ $delta = $deltacheck;
} else {
$delta = ($self->total()) / (1 + $self->count());
}