From: Vsevolod Stakhov Date: Wed, 19 Sep 2018 13:33:34 +0000 (+0100) Subject: [Minor] Fix selectors iterators operations X-Git-Tag: 1.8.0~65 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3f158ae4b49660d38f02bcca6b08f66fce974c19;p=rspamd.git [Minor] Fix selectors iterators operations --- 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)