summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-09-13 15:16:08 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-09-13 15:16:08 +0100
commit5c78058e6eb6e303e27056d6cb338a22fadbab18 (patch)
treef29ccd05acbf65ec970ce4dd3bc57b1cd2127582
parent5d079bd4837987013f34a43eacc5b7f6ae589996 (diff)
downloadrspamd-5c78058e6eb6e303e27056d6cb338a22fadbab18.tar.gz
rspamd-5c78058e6eb6e303e27056d6cb338a22fadbab18.zip
[Minor] Add generic list type for processors in selectors
-rw-r--r--lualib/lua_selectors.lua18
1 files changed, 7 insertions, 11 deletions
diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua
index 112443fd3..66f2906d1 100644
--- a/lualib/lua_selectors.lua
+++ b/lualib/lua_selectors.lua
@@ -302,10 +302,7 @@ local transform_function = {
-- Returns the first element
['first'] = {
['types'] = {
- ['url_list'] = true,
- ['kv_list'] = true,
- ['received_list'] = true,
- ['string_list'] = true
+ ['list'] = true,
},
['process'] = function(inp, t)
return inp[1],pure_type(t)
@@ -315,9 +312,7 @@ local transform_function = {
-- Returns the last element
['last'] = {
['types'] = {
- ['url_list'] = true,
- ['kv_list'] = true,
- ['string_list'] = true
+ ['list'] = true,
},
['process'] = function(inp, t)
return inp[#inp],pure_type(t)
@@ -327,9 +322,7 @@ local transform_function = {
-- Returns the nth element
['nth'] = {
['types'] = {
- ['url_list'] = true,
- ['kv_list'] = true,
- ['string_list'] = true
+ ['list'] = true,
},
['process'] = function(inp, t, args)
return inp[tonumber(args[1] or 1)],pure_type(t)
@@ -470,7 +463,10 @@ local function process_selector(task, sel)
if not x.types[t] then
-- Additional case for map
local pt = pure_type(t, '^(.*)_list$')
- if pt and x.map_type and x.types[pt] then
+ if x.types['list'] then
+ -- Generic list
+ return {x.process(value, t, x.args)}
+ elseif pt and x.map_type and x.types[pt] then
return {fun.map(function(list_elt)
local ret, _ = x.process(list_elt, pt, x.args)
return ret