You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by fe...@apache.org on 2004/05/10 07:10:11 UTC

svn commit: rev 10574 - incubator/spamassassin/trunk/lib/Mail/SpamAssassin

Author: felicity
Date: Sun May  9 22:10:10 2004
New Revision: 10574

Modified:
   incubator/spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm
Log:
bug 3366: a from address of 'foo@bar...' was causing issues with Net::DNS.  1) don't bother doing an A or MX lookup on 'bar...' -- trim it to 'bar.', then notice that it's not at made up of at least 2 parts and skip.  2) in all_from_addrs, unique the list of addresses, and also deal with the 'bar...' names -- squish to 'bar.'.

Modified: incubator/spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm
==============================================================================
--- incubator/spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm	(original)
+++ incubator/spamassassin/trunk/lib/Mail/SpamAssassin/EvalTests.pm	Sun May  9 22:10:10 2004
@@ -89,11 +89,20 @@
 sub _check_for_from_dns {
   my ($self) = @_;
 
-  my $from = $self->get ('Reply-To:addr');
-  if (!defined $from || $from !~ /\@\S+/) {
-    $from = $self->get ('From:addr');
+  my $from;
+  foreach $from ( $self->get('Reply-To:addr'), $self->get ('From:addr') ) {
+    next unless defined $from;
+
+    # bug 3366
+    $from =~ tr/././s;
+
+    if ($from =~ /\@(\S+\.\S+)/) {
+      $from = $1;
+      last;
+    }
+    undef $from;
   }
-  return 0 unless ($from =~ /\@(\S+)/);
+  return 0 unless (defined $from);
   $from = $1;
 
   # First check that DNS is available, if not do not perform this check
@@ -1071,7 +1080,9 @@
     # FNs for things like whitelist_from.  Since all of these are From
     # headers, there should only be 1 address in each anyway, so use the
     # :addr code...
-    @addrs = grep { defined($_) && length($_) > 0 }
+    # bug 3366: some addresses come in as 'foo@bar...', which is invalid.
+    # so deal with the multiple periods.
+    @addrs = grep { defined($_) && length($_) > 0 } map { tr/././s; $_; }
         ($self->get ('From:addr'),                  # std
          $self->get ('Envelope-Sender:addr'),       # qmail: new-inject(1)
          $self->get ('Resent-Sender:addr'),         # procmailrc manpage
@@ -1079,6 +1090,10 @@
          $self->get ('EnvelopeFrom:addr'));	    # SMTP envelope
     # http://www.cs.tut.fi/~jkorpela/headers.html is useful here
   }
+
+  # Remove duplicate addresses
+  my %addrs = map { $_ => 1 } @addrs;
+  @addrs = keys %addrs;
 
   dbg ("all '*From' addrs: ".join (" ", @addrs));
   $self->{all_from_addrs} = \@addrs;