Committed, thanks
 Giovanni

On 11/22/24 5:56 PM, Kent Oyer wrote:
Hi Giovanni,

I think you can eliminate the check $host eq "www.$domain" because $domain is 
derived from $host.

Index: lib/Mail/SpamAssassin/Plugin/Redirectors.pm
===================================================================
--- lib/Mail/SpamAssassin/Plugin/Redirectors.pm (revision 1922028)
+++ lib/Mail/SpamAssassin/Plugin/Redirectors.pm (working copy)
@@ -720,7 +720,7 @@
    # on the www domain
    elsif($levels == 2 && $host =~ /^www\.([^.]+\.[^.]+)$/i) {
      my $domain = $1;
-    if(($host eq "www.$domain") and exists $conf->{url_redirector}->{$domain}) 
{
+    if(exists $conf->{url_redirector}->{$domain}) {
        dbg("Found internal www redirection for domain $domain");
        return {
          'uri' => $uri,


Thanks
Kent

On Fri, Nov 22, 2024 at 10:01 AM, gbec...@apache.org wrote:

    
------------------------------------------------------------------------------------------------------------------
    CAUTION: External email from: gbechis@‌apache.‌org
    Use caution before clicking on links or opening attachments.
    
------------------------------------------------------------------------------------------------------------------
    Author: gbechis
    Date: Fri Nov 22 15:59:18 2024
    New Revision: 1922027

    URL: http://svn.apache.org/viewvc?rev=1922027&view=rev 
<http://svn.apache.org/viewvc?rev=1922027&view=rev>
    Log:
    always use the correct http method
    prefer configured redirectors when searching for urls

    Modified:
    spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Redirectors.pm

    Modified: spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Redirectors.pm
    URL: 
http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Redirectors.pm?rev=1922027&r1=1922026&r2=1922027&view=diff
 
<http://svn.apache.org/viewvc/spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Redirectors.pm?rev=1922027&r1=1922026&r2=1922027&view=diff>
    
==============================================================================
    --- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Redirectors.pm 
(original)
    +++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Redirectors.pm Fri Nov 
22 15:59:18 2024
    @@ -720,18 +720,17 @@ sub _check_redirector_uri {
    # on the www domain
    elsif($levels == 2 && $host =~ /^www\.([^.]+\.[^.]+)$/i) {
    my $domain = $1;
    -    if ($newuri = _check_querystring($params, $conf)) {
    -      return {
    -        'uri' => $newuri,
    -        'method' => 'head',
    -      };
    -    }
    if(($host eq "www.$domain" <http://www.%24domain>) and exists 
$conf->{url_redirector}->{$domain}) {
    dbg("Found internal www redirection for domain $domain");
    return {
    'uri' => $uri,
    'method' => $conf->{url_redirector}->{$domain} == 1 ? 'head' : 'get',
    };
    +    } elsif ($newuri = _check_querystring($params, $conf)) {
    +      return {
    +        'uri' => $newuri,
    +        'method' => 'head',
    +      };
    }
    }
    # if domain is a 3rd level domain check if there is a url redirector
    @@ -744,15 +743,19 @@ sub _check_redirector_uri {
    };
    }
    elsif ($host =~ /(\.[a-z0-9_]+(?:\.[a-z0-9_]+)?\.[a-z]+)$/i &&
    -           exists $conf->{url_redirector}->{$1}) {
    +    exists $conf->{url_redirector}->{$1}) {
    return {
    'uri' => $uri,
    'method' => $conf->{url_redirector}->{$1} == 1 ? 'head' : 'get',
    };
    } elsif ($newuri = _check_querystring($params, $conf)) {
    +    my $nhost = $newuri;
    +    if($nhost =~ /https?:\/\/(.*)/) {
    +      $nhost = $1;
    +    }
    return {
    'uri' => $newuri,
    -      'method' => 'head',
    +      'method' => (exists($conf->{url_redirector}->{$nhost}) && 
($conf->{url_redirector}->{$nhost} == 1)) ? 'head' : 'get',
    };
    } else {
    dbg("No explicit redirector host found for $host");


Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to