commit f4a6e61: [Fix] Fix various issues in the `url_redirector` plugin
Vsevolod Stakhov
vsevolod at rspamd.com
Thu Sep 7 15:35:04 UTC 2023
Author: Vsevolod Stakhov
Date: 2023-09-07 16:29:08 +0100
URL: https://github.com/rspamd/rspamd/commit/f4a6e61ef789c6e472a89ffa2a7ead7141ae8593 (HEAD -> master)
[Fix] Fix various issues in the `url_redirector` plugin
---
src/plugins/lua/url_redirector.lua | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/plugins/lua/url_redirector.lua b/src/plugins/lua/url_redirector.lua
index 092fb7def..10b5fb255 100644
--- a/src/plugins/lua/url_redirector.lua
+++ b/src/plugins/lua/url_redirector.lua
@@ -178,14 +178,16 @@ end
-- Orig url is the original url object
-- url should be a new url object...
local function resolve_cached(task, orig_url, url, key, ntries)
+ local str_url = tostring(url or "")
local function resolve_url()
if ntries > settings.nested_limit then
-- We cannot resolve more, stop
rspamd_logger.debugm(N, task, 'cannot get more requests to resolve %s, stop on %s after %s attempts',
orig_url, url, ntries)
cache_url(task, orig_url, url, key, 'nested')
+ local str_orig_url = tostring(orig_url)
task:insert_result(settings.redirector_symbol_nested, 1.0,
- string.format('%s->%s:%d', maybe_trim_url(orig_url), maybe_trim_url(url), ntries))
+ string.format('%s->%s:%d', maybe_trim_url(str_orig_url), maybe_trim_url(str_url), ntries))
return
end
@@ -261,7 +263,7 @@ local function resolve_cached(task, orig_url, url, key, ntries)
headers = {
['User-Agent'] = ua,
},
- url = tostring(url),
+ url = str_url,
task = task,
method = 'head',
max_size = settings.max_size,
@@ -278,12 +280,12 @@ local function resolve_cached(task, orig_url, url, key, ntries)
-- Got cached result
rspamd_logger.debugm(N, task, 'found cached redirect from %s to %s',
url, data)
- if data.sub(1, 1) == '^' then
+ if data:sub(1, 1) == '^' then
-- Prefixed url stored
local prefix, new_url = data:match('^%^(%a+):(.+)$')
if prefix == 'nested' then
task:insert_result(settings.redirector_symbol_nested, 1.0,
- string.format('%s->%s:cached', maybe_trim_url(url), maybe_trim_url(new_url)))
+ string.format('%s->%s:cached', maybe_trim_url(str_url), maybe_trim_url(new_url)))
end
data = new_url
end
More information about the Commits
mailing list