]> git.proxmox.com Git - pmg-api.git/commitdiff
ruledb: spam: adapt to spamassassin 4.0.0
authorStoiko Ivanov <s.ivanov@proxmox.com>
Mon, 13 Mar 2023 21:23:44 +0000 (22:23 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 15 Mar 2023 15:51:28 +0000 (16:51 +0100)
find_all_addrs_in_line was changed to require an instantiated
Mail::SpamAssassin instance in:
https://github.com/apache/spamassassin/commit/139adfb5901b27fa13dccbf3a66c53ca7613f733
(read-only git mirror of the authoritative SVN)

Noticed while using `mutt` and bouncing mails, which adds Resent
headers.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
src/PMG/RuleDB/Spam.pm

index 14d7beabb8cd56c9d2fa3463e36cd16769f8a20c..a0b8f26e61367cf2d52f8a80c027ddcee9544c2f 100644 (file)
@@ -300,13 +300,13 @@ sub __get_addr {
 # because we do not call spamassassin in canes of commtouch match
 # see Mail::Spamassassin:PerMsgStatus for details
 sub __all_from_addrs {
-    my ($head) = @_;
+    my ($head, $spamtest) = @_;
 
     my @addrs;
 
     my $resent = $head->get('Resent-From');
     if (defined($resent) && $resent =~ /\S/) {
-       @addrs = Mail::SpamAssassin->find_all_addrs_in_line($resent);
+       @addrs = $spamtest->find_all_addrs_in_line($resent);
     } else {
        @addrs = map { tr/././s; $_ } grep { $_ ne '' }
         (__get_addr($head, 'From'),            # std
@@ -330,6 +330,8 @@ sub analyze_spam {
 
     $maxspamsize = 200*1024 if !$maxspamsize;
 
+    my $spamtest = $queue->{sa};
+
     my ($sa_score, $sa_max, $sa_scores, $sa_sumary, $list, $autolearn, $bayes, $loglist);
     $list = '';
     $loglist = '';
@@ -345,7 +347,7 @@ sub analyze_spam {
     }
 
     my $fromhash = { $queue->{from} => 1 }; 
-    foreach my $f (__all_from_addrs($entity->head())) {
+    foreach my $f (__all_from_addrs($entity->head(), $spamtest)) {
        $fromhash->{$f} = 1;
     }
     $queue->{all_from_addrs} = [ keys %$fromhash ];
@@ -373,8 +375,6 @@ sub analyze_spam {
 
     my ($csec, $usec) = gettimeofday ();
 
-    my $spamtest = $queue->{sa};
-
     # only run SA in testmode or when clamav_heuristic did not confirm spam (score < 5)
     if ($msginfo->{testmode} || ($sa_score < 5)) {