aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-11-13 11:29:41 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-11-13 11:30:00 +0000
commitd4fa8bac0ab2e98168350c00a3053612d736d40d (patch)
treefd9111bf07530386a5f0685cc5511c4ef9738e35
parent01872d6ac7a1ab4ad564b9b15b2620b2db72a2ae (diff)
downloadrspamd-d4fa8bac0ab2e98168350c00a3053612d736d40d.tar.gz
rspamd-d4fa8bac0ab2e98168350c00a3053612d736d40d.zip
[Fix] Deduct type of a table methods
-rw-r--r--lualib/lua_selectors/init.lua26
1 files changed, 15 insertions, 11 deletions
diff --git a/lualib/lua_selectors/init.lua b/lualib/lua_selectors/init.lua
index 8de79f767..54d42f242 100644
--- a/lualib/lua_selectors/init.lua
+++ b/lualib/lua_selectors/init.lua
@@ -338,20 +338,24 @@ exports.parse_selector = function(cfg, str)
},
map_type = 'string',
process = function(inp, t, args)
+ local ret
if t == 'table' then
- return inp[method_name],'string'
+ -- Plain table field
+ ret = inp[method_name]
else
-- We call method unpacking arguments and dropping all but the first result returned
- local ret = (inp[method_name](inp, unpack_function(args or E)))
- local ret_type = type(ret)
- -- Now apply types heuristic
- if ret_type == 'string' then
- return ret,'string'
- elseif ret_type == 'table' then
- return ret,'string_list'
- else
- return implicit_tostring(ret_type, ret)
- end
+ ret = (inp[method_name](inp, unpack_function(args or E)))
+ 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'
+ else
+ return implicit_tostring(ret_type, ret)
end
end,
}