svn commit: r1934572 - spamassassin/trunk/lib/Mail/SpamAssassin

[email protected] Mon, 25 May 2026 02:04:19 -0000
Newsgroups gmane.mail.spam.spamassassin.cvs
Message-ID <177967465998.3058476.10033288599398571915@svn03-he-fi>
Author: fkento
Date: Mon May 25 02:04:19 2026
New Revision: 1934572

Log:
HTML: strip internal whitespace from http/https/ftp URIs in canon_uri

Some mailers soft-wrap long href values by inserting CRLF+space mid-URL.
MUAs strip that whitespace at click time, but SpamAssassin previously
kept it, leaving the URI mangled. The Redirectors plugin needs the
unmangled URL to follow shorteners/redirectors to their destination,
so canonicalize the URI by collapsing internal whitespace for
http/https/ftp schemes.

Modified:
   spamassassin/trunk/lib/Mail/SpamAssassin/HTML.pm

Modified: spamassassin/trunk/lib/Mail/SpamAssassin/HTML.pm
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/HTML.pm	Mon May 25 00:25:28 2026	(r1934571)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/HTML.pm	Mon May 25 02:04:19 2026	(r1934572)
@@ -418,6 +418,13 @@ sub canon_uri {
   $uri =~ s/^[\s\xA0]+//;
   $uri =~ s/[\s\xA0]+$//;
 
+  # ... and for http/https/ftp, also strip internal whitespace. Some mailers
+  # soft-wrap long href values by inserting CRLF+space mid-URL; MUAs strip
+  # that whitespace at click time, so match that behavior.
+  if ($uri =~ /^(?:https?|ftp):/i) {
+    $uri =~ s/[\s\xA0]+//g;
+  }
+
   # Make sure all the URIs are nice and short
   if (length $uri > MAX_URI_LENGTH) {
     $self->{'uri_truncated'} = 1;