You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by he...@apache.org on 2021/04/18 15:13:18 UTC

svn commit: r1888907 - in /spamassassin/branches/3.4: lib/Mail/SpamAssassin/PerMsgStatus.pm lib/Mail/SpamAssassin/Util.pm t/uri.t

Author: hege
Date: Sun Apr 18 15:13:18 2021
New Revision: 1888907

URL: http://svn.apache.org/viewvc?rev=1888907&view=rev
Log:
Bug 7891 - spamassassin expands domain by wrong TLD

Modified:
    spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm
    spamassassin/branches/3.4/lib/Mail/SpamAssassin/Util.pm
    spamassassin/branches/3.4/t/uri.t

Modified: spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm?rev=1888907&r1=1888906&r2=1888907&view=diff
==============================================================================
--- spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm (original)
+++ spamassassin/branches/3.4/lib/Mail/SpamAssassin/PerMsgStatus.pm Sun Apr 18 15:13:18 2021
@@ -2538,7 +2538,7 @@ sub add_uri_detail_list {
   if ($types->{nocanon}) {
     push @uris, $uri;
   } else {
-    @uris = uri_list_canonicalize($self->{conf}->{redirector_patterns}, $uri);
+    @uris = uri_list_canonicalize($self->{conf}->{redirector_patterns}, [$uri], $self->{main}->{registryboundaries});
   }
   foreach my $cleanuri (@uris) {
     # Make sure all the URIs are nice and short

Modified: spamassassin/branches/3.4/lib/Mail/SpamAssassin/Util.pm
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.4/lib/Mail/SpamAssassin/Util.pm?rev=1888907&r1=1888906&r2=1888907&view=diff
==============================================================================
--- spamassassin/branches/3.4/lib/Mail/SpamAssassin/Util.pm (original)
+++ spamassassin/branches/3.4/lib/Mail/SpamAssassin/Util.pm Sun Apr 18 15:13:18 2021
@@ -1315,7 +1315,23 @@ sub secure_tmpdir {
 
 *uri_list_canonify = \&uri_list_canonicalize;  # compatibility alias
 sub uri_list_canonicalize {
-  my($redirector_patterns, @uris) = @_;
+  my $redirector_patterns = shift;
+
+  my @uris;
+  my $rb;
+  if (ref($_[0]) eq 'ARRAY') {
+    # New call style:
+    # - reference to array of redirector_patterns
+    # - reference to array of URIs
+    # - reference to $self->{main}->{registryboundaries}
+    @uris = @{$_[0]};
+    $rb = $_[1];
+  } else {
+    # Old call style:
+    # - reference to array of redirector_patterns
+    # - rest of the arguments is list of uris
+    @uris = @_;
+  }
 
   # make sure we catch bad encoding tricks
   my @nuris;
@@ -1537,7 +1553,10 @@ sub uri_list_canonicalize {
       elsif ($proto eq 'http://' && $auth eq '' &&
              $host ne 'localhost' && $port eq '80' &&
              $host =~ /^(?:www\.)?([^.]+)$/) {
-        push(@nuris, join('', $proto, 'www.', $1, '.com', $rest));
+        # Do not add .com to already valid schemelessly parsed domains (Bug 7891)
+        unless (defined $rb && $rb->is_domain_valid($host)) {
+          push(@nuris, join('', $proto, 'www.', $1, '.com', $rest));
+        }
       }
     }
   }

Modified: spamassassin/branches/3.4/t/uri.t
URL: http://svn.apache.org/viewvc/spamassassin/branches/3.4/t/uri.t?rev=1888907&r1=1888906&r2=1888907&view=diff
==============================================================================
--- spamassassin/branches/3.4/t/uri.t (original)
+++ spamassassin/branches/3.4/t/uri.t Sun Apr 18 15:13:18 2021
@@ -16,7 +16,7 @@ if (-e 'test_dir') {            # runnin
 }
 
 use strict;
-use Test::More tests => 102;
+use Test::More tests => 103;
 use lib '.'; use lib 't';
 use SATest; sa_t_init("uri");
 
@@ -130,7 +130,7 @@ sub array_cmp {
 sub try_canon {
   my($input, $expect) = @_;
   my $redirs = $sa->{conf}->{redirector_patterns};
-  my @input = sort { $a cmp $b } Mail::SpamAssassin::Util::uri_list_canonify($redirs, @{$input});
+  my @input = sort { $a cmp $b } Mail::SpamAssassin::Util::uri_list_canonicalize($redirs, $input, $sa->{registryboundaries});
   my @expect = sort { $a cmp $b } @{$expect};
 
   # output what we want/get for debugging
@@ -284,6 +284,12 @@ ok (try_canon([
    'http://foo/',
    'http://www.foo.com/',
        ]));
+# Bug 7891
+ok (try_canon([
+   'http://www.ch/',
+   ], [
+   'http://www.ch/'
+       ]));
 
 ##############################################