summaryrefslogtreecommitdiffstats
path: root/lualib/lua_selectors.lua
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-09-21 15:53:01 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-09-21 15:53:01 +0100
commit79c9041332e740150f6a9376e27f99ca568456e3 (patch)
treef4753dc01e8fead2a04934dc27948fb00dd36130 /lualib/lua_selectors.lua
parent5fc95db5da1f3f099bd6be53dea965bcea669307 (diff)
downloadrspamd-79c9041332e740150f6a9376e27f99ca568456e3.tar.gz
rspamd-79c9041332e740150f6a9376e27f99ca568456e3.zip
[Minor] Order selector valus how user placed them in the config
Diffstat (limited to 'lualib/lua_selectors.lua')
-rw-r--r--lualib/lua_selectors.lua34
1 files changed, 8 insertions, 26 deletions
diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua
index 21efc4573..15bf9e312 100644
--- a/lualib/lua_selectors.lua
+++ b/lualib/lua_selectors.lua
@@ -894,41 +894,23 @@ exports.combine_selectors = function(_, selectors, delimiter)
else
-- We need to do a spill on each table selector
-- e.g. s:tbl:s -> s:telt1:s + s:telt2:s ...
- local prefix = {}
local tbl = {}
- local suffix = {}
local res = {}
local in_prefix = true
for _,s in ipairs(selectors) do
- if in_prefix then
- if type(s) == 'string' then
- table.insert(prefix, s)
- elseif type(s) == 'userdata' then
- table.insert(prefix, tostring(s))
- else
- in_prefix = false
- table.insert(tbl, s)
- end
+ if type(s) == 'string' then
+ tbl[#tbl + 1] = fun.duplicate(s)
+ elseif type(s) == 'userdata' then
+ tbl[#tbl + 1] = fun.duplicate(tostring(s))
else
- if type(s) == 'string' then
- table.insert(suffix, s)
- elseif type(s) == 'userdata' then
- table.insert(suffix, tostring(s))
- else
- table.insert(tbl, s)
- end
+ tbl[#tbl + 1] = s
end
end
- prefix = table.concat(prefix, delimiter)
- suffix = table.concat(suffix, delimiter)
-
- for _,t in ipairs(tbl) do
- fun.each(function(...)
- table.insert(res, table.concat({...}, delimiter))
- end, fun.zip(fun.duplicate(prefix), t, fun.duplicate(suffix)))
- end
+ fun.each(function(...)
+ table.insert(res, table.concat({...}, delimiter))
+ end, fun.zip(lua_util.unpack(tbl)))
return res
end