diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-09-19 14:33:34 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-09-19 14:33:53 +0100 |
commit | 3f158ae4b49660d38f02bcca6b08f66fce974c19 (patch) | |
tree | 39c74bf483617d6c99fb36f7b7f37a252691d685 /lualib/lua_selectors.lua | |
parent | ba47061e73805d056307c5e51591b4632b3d2d63 (diff) | |
download | rspamd-3f158ae4b49660d38f02bcca6b08f66fce974c19.tar.gz rspamd-3f158ae4b49660d38f02bcca6b08f66fce974c19.zip |
[Minor] Fix selectors iterators operations
Diffstat (limited to 'lualib/lua_selectors.lua')
-rw-r--r-- | lualib/lua_selectors.lua | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua index dbb537010..b39771e33 100644 --- a/lualib/lua_selectors.lua +++ b/lualib/lua_selectors.lua @@ -353,7 +353,7 @@ local transform_function = { ['list'] = true, }, ['process'] = function(inp, t) - return inp[1],pure_type(t) + return fun.head(inp),pure_type(t) end, ['description'] = 'Returns the first element', }, @@ -363,7 +363,7 @@ local transform_function = { ['list'] = true, }, ['process'] = function(inp, t) - return inp[#inp],pure_type(t) + return fun.nth(#inp, inp),pure_type(t) end, ['description'] = 'Returns the last element', }, @@ -373,7 +373,7 @@ local transform_function = { ['list'] = true, }, ['process'] = function(inp, t, args) - return inp[tonumber(args[1] or 1)],pure_type(t) + return fun.nth(tonumber(args[1]) or 1, inp),pure_type(t) end, ['description'] = 'Returns the nth element', }, @@ -401,7 +401,7 @@ local transform_function = { ['string_list'] = true }, ['process'] = function(inp, _, args) - return table.concat(inp, args[1] or ''), 'string' + return table.concat(fun.totable(inp), args[1] or ''), 'string' end, ['description'] = 'Joins strings into a single string using separator in the argument', }, @@ -488,7 +488,8 @@ local transform_function = { -- Drops input value and return values from function's arguments or an empty string ['id'] = { ['types'] = { - ['string'] = true + ['string'] = true, + ['list'] = true, }, ['map_type'] = 'string', ['process'] = function(_, _, args) |