aboutsummaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-11-26 12:29:09 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-11-26 12:29:09 +0000
commita1b9dffcf77bbb129d267a422e68721f9e034f11 (patch)
tree70d474e6c1f8b53da521ae6b01bb5e3880dcbcdd /lualib
parent6dd9308b316987ca92926cb988644a45fa86f04d (diff)
downloadrspamd-a1b9dffcf77bbb129d267a422e68721f9e034f11.tar.gz
rspamd-a1b9dffcf77bbb129d267a422e68721f9e034f11.zip
[Fix] Fix text selectors
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_selectors/init.lua21
1 files changed, 17 insertions, 4 deletions
diff --git a/lualib/lua_selectors/init.lua b/lualib/lua_selectors/init.lua
index 3839cec9e..cc44d0b01 100644
--- a/lualib/lua_selectors/init.lua
+++ b/lualib/lua_selectors/init.lua
@@ -456,12 +456,24 @@ exports.combine_selectors = function(_, selectors, delimiter)
if not selectors then return nil end
- local all_strings = fun.all(function(s) return type(s) == 'string' end, selectors)
+ local have_tables, have_userdata
- if all_strings then
- return table.concat(selectors, delimiter)
+ for _,s in ipairs(selectors) do
+ if type(s) == 'table' then
+ have_tables = true
+ elseif type(s) == 'userdata' then
+ have_userdata = true
+ end
+ end
+
+ if not have_tables then
+ if not have_userdata then
+ return table.concat(selectors, delimiter)
+ else
+ return rspamd_text.fromtable(selectors, delimiter)
+ end
else
- -- We need to do a spill on each table selector
+ -- We need to do a spill on each table selector and make a cortezian product
-- e.g. s:tbl:s -> s:telt1:s + s:telt2:s ...
local tbl = {}
local res = {}
@@ -472,6 +484,7 @@ exports.combine_selectors = function(_, selectors, delimiter)
elseif type(s) == 'userdata' then
rawset(tbl, i, fun.duplicate(tostring(s)))
else
+ -- Raw table
rawset(tbl, i, s)
end
end