aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_selectors
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-02-25 10:45:59 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-02-25 10:45:59 +0000
commit60396f2478b0f7284b42139d6d8e05bf81b12b20 (patch)
treef6ed29e3b08449a5dd2a7aaa1864129f6e0659ca /lualib/lua_selectors
parent09a4d1ecff0d80dbbd9ce74a5f13935370810fcc (diff)
downloadrspamd-60396f2478b0f7284b42139d6d8e05bf81b12b20.tar.gz
rspamd-60396f2478b0f7284b42139d6d8e05bf81b12b20.zip
[Fix] Selectors: Filter nil elements in lists
Diffstat (limited to 'lualib/lua_selectors')
-rw-r--r--lualib/lua_selectors/init.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/lualib/lua_selectors/init.lua b/lualib/lua_selectors/init.lua
index cc44d0b01..9a4af2e04 100644
--- a/lualib/lua_selectors/init.lua
+++ b/lualib/lua_selectors/init.lua
@@ -349,13 +349,18 @@ exports.parse_selector = function(cfg, str)
ret = (inp[method_name](inp, unpack_function(args or E)))
end
+ -- Do not go further
+ if not ret then return nil end
+
local ret_type = type(ret)
-- Now apply types heuristic
if ret_type == 'string' then
return ret,'string'
- elseif ret_type == 'table' then
- -- TODO: we need to ensure that 1) table is numeric 2) table has merely strings
- return ret,'string_list'
+ elseif ret_type == 'table' and ret[1] ~= nil then
+ local filt_predicate = fun.filter(function(elt)
+ return elt ~= nil
+ end, ret)
+ return filt_predicate, 'string_list'
else
return implicit_tostring(ret_type, ret)
end