summaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-16 20:02:45 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-16 20:02:45 +0100
commite872fbfb5ea795568017dd97db8fffc827d89da3 (patch)
treed79c10c58497cd3017152cb2455c68cc4823c365 /lualib
parent0df7ec0530650f972e3f48850c092bee15317ff2 (diff)
downloadrspamd-e872fbfb5ea795568017dd97db8fffc827d89da3.tar.gz
rspamd-e872fbfb5ea795568017dd97db8fffc827d89da3.zip
[Minor] Selectors: Add append/prepend transforms
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_selectors.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua
index 3bc7b9d75..a55d0742b 100644
--- a/lualib/lua_selectors.lua
+++ b/lualib/lua_selectors.lua
@@ -494,6 +494,32 @@ the second argument is optional hash type (`blake2`, `sha256`, `sha1`, `sha512`,
['args_schema'] = {(ts.number + ts.string / tonumber):is_optional(),
(ts.number + ts.string / tonumber):is_optional()}
},
+ -- Prepends a string or a strings list
+ ['prepend'] = {
+ ['types'] = {
+ ['string'] = true
+ },
+ ['map_type'] = 'string',
+ ['process'] = function(inp, _, args)
+ local prepend = table.concat(args, '')
+
+ return prepend .. inp, 'string'
+ end,
+ ['description'] = 'Prepends a string or a strings list',
+ },
+ -- Appends a string or a strings list
+ ['append'] = {
+ ['types'] = {
+ ['string'] = true
+ },
+ ['map_type'] = 'string',
+ ['process'] = function(inp, _, args)
+ local append = table.concat(args, '')
+
+ return inp .. append, 'string'
+ end,
+ ['description'] = 'Appends a string or a strings list',
+ },
-- Regexp matching
['regexp'] = {
['types'] = {