You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by mm...@apache.org on 2014/11/04 17:24:04 UTC

svn commit: r1636637 - in /spamassassin/trunk/lib/Mail/SpamAssassin: Conf.pm PerMsgStatus.pm Plugin/AskDNS.pm

Author: mmartinec
Date: Tue Nov  4 16:24:04 2014
New Revision: 1636637

URL: http://svn.apache.org/r1636637
Log:
Bug 7099: Adding tags SENDERDOMAIN and AUTHORDOMAIN

Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm?rev=1636637&r1=1636636&r2=1636637&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Conf.pm Tue Nov  4 16:24:04 2014
@@ -4003,6 +4003,11 @@ optional, and the default is shown below
  _DATE_            rfc-2822 date of scan
  _STARS(*)_        one "*" (use any character) for each full score point
                    (note: limited to 50 'stars')
+ _SENDERDOMAIN_    a domain name of the envelope sender address, lowercased
+ _AUTHORDOMAIN_    a domain name of the author address (the From header
+                   field), lowercased;  note that RFC 5322 allows a mail
+                   message to have multiple authors - currently only the
+                   domain name of the first email address is returned
  _RELAYSTRUSTED_   relays used and deemed to be trusted (see the 
                    'X-Spam-Relays-Trusted' pseudo-header)
  _RELAYSUNTRUSTED_ relays used that can not be trusted (see the 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=1636637&r1=1636636&r2=1636637&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/PerMsgStatus.pm Tue Nov  4 16:24:04 2014
@@ -1714,6 +1714,26 @@ sub extract_message_metadata {
     $self->{$item} = $self->{msg}->{metadata}->{$item};
   }
 
+  # TODO: International domain names (UTF-8) must be converted to
+  # ASCII-compatible encoding (ACE) for the purpose of setting the
+  # SENDERDOMAIN and AUTHORDOMAIN tags (and probably for other uses too).
+  # (explicitly required for DMARC, draft-kucherawy-dmarc-base sect. 5.6.1)
+  #
+  { local $1;
+    my $addr = $self->get('EnvelopeFrom:addr', undef);
+    # collect a FQDN, ignoring potential trailing WSP
+    if (defined $addr && $addr =~ /\@([^@. \t]+\.[^@ \t]+?)[ \t]*\z/s) {
+      $self->set_tag('SENDERDOMAIN', lc $1);
+    }
+    # TODO: the get ':addr' only returns the first address; this should be
+    # augmented to be able to return all addresses in a header field, multiple
+    # addresses in a From header field are allowed according to RFC 5322
+    $addr = $self->get('From:addr', undef);
+    if (defined $addr && $addr =~ /\@([^@. \t]+\.[^@ \t]+?)[ \t]*\z/s) {
+      $self->set_tag('AUTHORDOMAIN', lc $1);
+    }
+  }
+
   $self->set_tag('RELAYSTRUSTED',   $self->{relays_trusted_str});
   $self->set_tag('RELAYSUNTRUSTED', $self->{relays_untrusted_str});
   $self->set_tag('RELAYSINTERNAL',  $self->{relays_internal_str});
@@ -1967,7 +1987,7 @@ sub _get {
       $result = $self->{msg}->get_metadata($request);
     }
   }
-      
+
   # special queries
   if (defined $result && ($getaddr || $getname)) {
     local $1;
@@ -1991,7 +2011,7 @@ sub _get {
       $result =~ s/\s*\(.*?\)//g;
       # strip out the "quoted text", unless it's the only thing in the string
       if ($result !~ /^".*"$/) {
-        $result =~ s/(?<!<)"[^"]*"(?!@)//g;   #" emacs
+        $result =~ s/(?<!<)"[^"]*"(?!\@)//g;   #" emacs
       }
       # Foo Blah <jm...@xxx> or <jm...@xxx>
       local $1;
@@ -2767,7 +2787,7 @@ sub get_envelope_from {
     # make sure we get the most recent copy - there can be only one EnvelopeSender.
     $envf = $self->get($self->{conf}->{envelope_sender_header}.":addr",undef);
     # ok if it contains an "@" sign, or is "" (ie. "<>" without the < and >)
-    goto ok if defined $envf && ($envf =~ /\@/ || $envf =~ /^$/);
+    goto ok if defined $envf && ($envf =~ /\@/ || $envf eq '');
     # Warn them if it's configured, but not there or not usable.
     if (defined $envf) {
       chomp $envf;
@@ -2862,8 +2882,9 @@ sub get_envelope_from {
   return;
 
 ok:
-  $envf =~ s/^<*//gs;                # remove <
-  $envf =~ s/>*\s*$//gs;        # remove >, whitespace, newlines
+  $envf =~ s/^<*//s;            # remove <
+  $envf =~ s/>*\s*\z//s;        # remove >, whitespace, newlines
+
   return $envf;
 }
 

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm
URL: http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm?rev=1636637&r1=1636636&r2=1636637&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/AskDNS.pm Tue Nov  4 16:24:04 2014
@@ -557,7 +557,8 @@ sub process_response_packet {
   # the code handling such reply from DNS MUST assemble all of these
   # marshaled text blocks into a single one before any syntactical
   # verification takes place.
-  # The same goes for RFC 4408 (SPF), RFC 4871 (DKIM), RFC 5617 (ADSP) ...
+  # The same goes for RFC 4408 (SPF), RFC 4871 (DKIM), RFC 5617 (ADSP),
+  # draft-kucherawy-dmarc-base (DMARC), ...
 
   for my $rr (@answer) {
     my($rr_rdatastr, $rdatanum, $rr_type);