commit be88dfa: [Minor] Selectors: avoid returning empty list from extractors
Andrew Lewis
nerf at judo.za.org
Thu Oct 15 20:35:06 UTC 2020
Author: Andrew Lewis
Date: 2020-10-15 12:41:21 +0200
URL: https://github.com/rspamd/rspamd/commit/be88dfaade722b8c42d7d87f20eeeb8d889de24e (refs/pull/3519/head)
[Minor] Selectors: avoid returning empty list from extractors
---
lualib/lua_selectors/extractors.lua | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/lualib/lua_selectors/extractors.lua b/lualib/lua_selectors/extractors.lua
index 515d522cb..acb13deaa 100644
--- a/lualib/lua_selectors/extractors.lua
+++ b/lualib/lua_selectors/extractors.lua
@@ -241,7 +241,10 @@ The optional second argument accepts list of flags:
['received'] = {
['get_value'] = function(task, args)
local rh = task:get_received_headers()
- if args[1] and rh then
+ if not rh[1] then
+ return nil
+ end
+ if args[1] then
return fun.map(function(r) return r[args[1]] end, rh), 'string_list'
end
@@ -255,7 +258,10 @@ e.g. `by_hostname`]],
['urls'] = {
['get_value'] = function(task, args)
local urls = task:get_urls()
- if args[1] and urls then
+ if not urls[1] then
+ return nil
+ end
+ if args[1] then
return fun.map(function(r) return r[args[1]](r) end, urls), 'string_list'
end
return urls,'userdata_list'
@@ -271,6 +277,9 @@ e.g. `get_tld`]],
params.task = task
params.no_cache = true
local urls = lua_util.extract_specific_urls(params)
+ if not urls[1] then
+ return nil
+ end
return urls,'userdata_list'
end,
['description'] = [[Get most specific urls. Arguments are equal to the Lua API function]],
@@ -287,7 +296,10 @@ e.g. `get_tld`]],
['emails'] = {
['get_value'] = function(task, args)
local urls = task:get_emails()
- if args[1] and urls then
+ if not urls[1] then
+ return nil
+ end
+ if args[1] then
return fun.map(function(r) return r[args[1]](r) end, urls), 'string_list'
end
return urls,'userdata_list'
More information about the Commits
mailing list