From d1795dff994bcbacb8d0c4a03e4968df067e4256 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 25 Feb 2023 19:35:37 +0000 Subject: [PATCH] [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 -- 2.39.5