diff options
author | Andrew Lewis <nerf@judo.za.org> | 2020-10-15 12:41:21 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2020-10-15 13:32:05 +0200 |
commit | be88dfaade722b8c42d7d87f20eeeb8d889de24e (patch) | |
tree | 9ec6a9dbded53ef92f91b62920d97b59403daae5 /lualib | |
parent | 2986a7f98325b06341fc31a61954eb90e4086d84 (diff) | |
download | rspamd-be88dfaade722b8c42d7d87f20eeeb8d889de24e.tar.gz rspamd-be88dfaade722b8c42d7d87f20eeeb8d889de24e.zip |
[Minor] Selectors: avoid returning empty list from extractors
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_selectors/extractors.lua | 18 |
1 files 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' |