diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-08-22 15:50:14 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-08-22 15:50:14 +0100 |
commit | c352b641b1d28aa33817e524936bf08c8134c633 (patch) | |
tree | a1d12b27d9218f901f041e7cc2c89c5f5671e7a3 /lualib/lua_selectors.lua | |
parent | 924903d8b44eeb3a0f6da670c9ffe598fe736624 (diff) | |
download | rspamd-c352b641b1d28aa33817e524936bf08c8134c633.tar.gz rspamd-c352b641b1d28aa33817e524936bf08c8134c633.zip |
[Minor] Add id selector transform function
Diffstat (limited to 'lualib/lua_selectors.lua')
-rw-r--r-- | lualib/lua_selectors.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua index 3cf9a1340..995617ca0 100644 --- a/lualib/lua_selectors.lua +++ b/lualib/lua_selectors.lua @@ -360,6 +360,22 @@ local transform_function = { return inp:sub(start_pos, end_pos), 'string' end }, + -- Drops input value and return values from function's arguments or an empty string + ['id'] = { + ['types'] = { + ['string'] = true + }, + ['map_type'] = 'string', + ['process'] = function(_, _, args) + if args[1] and args[2] then + return fun.map(tostring, args) + elseif args[1] then + return args[1] + end + + return '' + end + }, -- Extracts table value from key-value list ['elt'] = { ['types'] = { |