summaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-09-21 16:48:43 +0100
committerGitHub <noreply@github.com>2018-09-21 16:48:43 +0100
commit605e578989187c3c31940b0fe5f1554c070221f5 (patch)
tree04621e515a5e2a766b2423509d50d3fdb8db3c44 /lualib
parent7a08e4a48a4bca88c79e7368297872adb69b83ed (diff)
parentd3ed598d36e60b58602d95d791258945b2c85aca (diff)
downloadrspamd-605e578989187c3c31940b0fe5f1554c070221f5.tar.gz
rspamd-605e578989187c3c31940b0fe5f1554c070221f5.zip
Merge pull request #2517 from negram/selector-user-defined-order
[Minor] Order selector values how user placed them in the config
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_selectors.lua37
1 files changed, 9 insertions, 28 deletions
diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua
index 21efc4573..f5018694f 100644
--- a/lualib/lua_selectors.lua
+++ b/lualib/lua_selectors.lua
@@ -894,41 +894,22 @@ 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
+ for i,s in ipairs(selectors) do
+ if type(s) == 'string' then
+ rawset(tbl, i, fun.duplicate(s))
+ elseif type(s) == 'userdata' then
+ rawset(tbl, i, 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
+ rawset(tbl, i, 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