aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_selectors/transforms.lua
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2020-11-11 09:47:02 +0200
committerAndrew Lewis <nerf@judo.za.org>2020-11-11 09:47:02 +0200
commit54e19913f1febb1cf5824e6c7f2cb277524e7c08 (patch)
treee396f85188c1b9b29aae73c7bdfc0dbe9437be31 /lualib/lua_selectors/transforms.lua
parent7b8171fa979d8a2b394616352856b03a49b9db48 (diff)
downloadrspamd-54e19913f1febb1cf5824e6c7f2cb277524e7c08.tar.gz
rspamd-54e19913f1febb1cf5824e6c7f2cb277524e7c08.zip
[Minor] Selectors: Add extractor & transform for metatokens
Diffstat (limited to 'lualib/lua_selectors/transforms.lua')
-rw-r--r--lualib/lua_selectors/transforms.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/lualib/lua_selectors/transforms.lua b/lualib/lua_selectors/transforms.lua
index 6251180ec..1a27b775d 100644
--- a/lualib/lua_selectors/transforms.lua
+++ b/lualib/lua_selectors/transforms.lua
@@ -441,6 +441,23 @@ Empty string comes the first argument or 'true', non-empty string comes nil]],
['description'] = 'Extracts tld from a hostname represented as a string',
['args_schema'] = {}
},
+ -- Converts list of strings to numbers and returns a packed string
+ ['pack_numbers'] = {
+ ['types'] = {
+ ['string_list'] = true
+ },
+ ['map_type'] = 'string',
+ ['process'] = function(inp, _, args)
+ local fmt = args[1] or 'f'
+ local res = {}
+ for _, s in ipairs(inp) do
+ table.insert(res, tonumber(s))
+ end
+ return rspamd_util.pack(string.rep(fmt, #res), lua_util.unpack(res)), 'string'
+ end,
+ ['description'] = 'Converts a list of strings to numbers & returns a packed string',
+ ['args_schema'] = {ts.string:is_optional()}
+ },
}
transform_function.match = transform_function.regexp