commit d1795df: [Minor] Honor more redirect 3xx codes

Vsevolod Stakhov vsevolod at rspamd.com
Sat Feb 25 19:42:03 UTC 2023


Author: Vsevolod Stakhov
Date: 2023-02-25 19:35:37 +0000
URL: https://github.com/rspamd/rspamd/commit/d1795dff994bcbacb8d0c4a03e4968df067e4256 (HEAD -> master)

[Minor] Honor more redirect 3xx codes
Issue: #4395

---
 src/plugins/lua/url_redirector.lua | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/plugins/lua/url_redirector.lua b/src/plugins/lua/url_redirector.lua
index 641d8de66..512e6a005 100644
--- a/src/plugins/lua/url_redirector.lua
+++ b/src/plugins/lua/url_redirector.lua
@@ -170,6 +170,14 @@ local function resolve_cached(task, orig_url, url, key, ntries)
       return
     end
 
+    local redirection_codes = {
+      [301] = true, -- moved permanently
+      [302] = true, -- found
+      [303] = true, -- see other
+      [307] = true, -- temporary redirect
+      [308] = true, -- permanent redirect
+    }
+
     local function http_callback(err, code, _, headers)
       if err then
         rspamd_logger.infox(task, 'found redirect error from %s to %s, err message: %s',
@@ -187,7 +195,7 @@ local function resolve_cached(task, orig_url, url, key, ntries)
 
           cache_url(task, orig_url, url, key)
 
-        elseif code == 301 or code == 302 then
+        elseif redirection_codes[code] then
           local loc = headers['location']
           local redir_url
           if loc then


More information about the Commits mailing list