You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spamassassin.apache.org by gb...@apache.org on 2025/07/07 21:21:01 UTC
svn commit: r1927063 - /spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Redirectors.pm
Author: gbechis
Date: Mon Jul 7 21:21:01 2025
New Revision: 1927063
URL: http://svn.apache.org/viewvc?rev=1927063&view=rev
Log:
handle redirectors that are using "http-equiv" html meta tag
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=1927063&r1=1927062&r2=1927063&view=diff
==============================================================================
--- spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Redirectors.pm (original)
+++ spamassassin/trunk/lib/Mail/SpamAssassin/Plugin/Redirectors.pm Mon Jul 7 21:21:01 2025
@@ -920,24 +920,42 @@ sub recursive_lookup {
dbg("URL is not a redirect: $redir_url = ".$response->status_line);
my $rcode = $response->code;
if ($rcode =~ /^\d{3}$/) {
- $pms->{"redir_url_$rcode"} = 1;
if($rcode eq 500) {
if($response->headers->{'client-warning'} eq 'Internal response') {
dbg("Connection timeout checking $redir_url");
}
+ } elsif($rcode eq 200) {
+ if((defined $response->content) and ($response->content =~ /http-equiv=["']?refresh["']?.*?content=["']?(\d+);url=((?:https?:\/\/)?[^"'\/\\]+)["']?/i)) {
+ my $delay = $1;
+ $location = $2;
+ if($delay eq 0) {
+ $rcode = 301;
+ } elsif ($delay > 0) {
+ $rcode = 302;
+ }
+ dbg("Found a meta http-equiv redirector, changing http response code from " . $response->code . " to $rcode");
+ }
+ } else {
+ $pms->{"redir_url_$rcode"} = 1;
+ # Update cache
+ $self->cache_add($redir_url, $rcode);
+ $pms->add_uri_detail_list($redir_url) if !$pms->{uri_detail_list}->{$redir_url};
}
- # Update cache
- $self->cache_add($redir_url, $rcode);
- $pms->add_uri_detail_list($redir_url) if !$pms->{uri_detail_list}->{$redir_url};
}
- return;
+ if($rcode !~ /^30[12]/) {
+ return;
+ }
}
- $location = $response->headers->{location};
- if($redir_url ne $location) {
- if ($conf->{url_redirector_loginfo}) {
- info("found $redir_url => $location");
- } else {
- dbg("found $redir_url => $location");
+
+ # if redirection has been done using http-equiv meta tag, location http header will not be available
+ if(exists $response->headers->{location}) {
+ $location = $response->headers->{location};
+ if($redir_url ne $location) {
+ if ($conf->{url_redirector_loginfo}) {
+ info("found $redir_url => $location");
+ } else {
+ dbg("found $redir_url => $location");
+ }
}
}
}