diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-04-18 10:19:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-18 10:19:05 +0100 |
commit | e81fe0882df81045ef43f9741546b5a60752b115 (patch) | |
tree | 0aab0f89071efbec3299a53587012029842e1009 /lualib/lua_selectors/transforms.lua | |
parent | 892383a5a2fe19a4da4ad7862e087eed3618d11d (diff) | |
parent | 00b2ecaa3b1ec5629a1c37781af80b7afa23913b (diff) | |
download | rspamd-e81fe0882df81045ef43f9741546b5a60752b115.tar.gz rspamd-e81fe0882df81045ef43f9741546b5a60752b115.zip |
Merge pull request #3336 from rm-minus-rf/master
[Feature] allow variables in force_actions messages
Diffstat (limited to 'lualib/lua_selectors/transforms.lua')
-rw-r--r-- | lualib/lua_selectors/transforms.lua | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lualib/lua_selectors/transforms.lua b/lualib/lua_selectors/transforms.lua index 5f1a4dca0..4cfff3654 100644 --- a/lualib/lua_selectors/transforms.lua +++ b/lualib/lua_selectors/transforms.lua @@ -417,8 +417,27 @@ Empty string comes the first argument or 'true', non-empty string comes nil]], ['args_schema'] = {(ts.number + ts.string / tonumber), (ts.number + ts.string / tonumber):is_optional()} }, + -- Returns the string(s) with all non ascii chars replaced + ['to_ascii'] = { + ['types'] = { + ['string'] = true, + ['list'] = true, + }, + ['map_type'] = 'string', + ['process'] = function(inp, _, args) + if type(inp) == 'table' then + return fun.map( function(s) return string.gsub(tostring(s), '[\128-\255]', args[1] or '?') end , inp), 'string_list' + else + return string.gsub(tostring(inp), '[\128-\255]', '?'), 'string' + end + + end, + ['description'] = 'Returns the string with all non-ascii bytes replaced with the character given as second argument or `?`', + ['args_schema'] = {ts.string:is_optional()} + }, + } transform_function.match = transform_function.regexp -return transform_function
\ No newline at end of file +return transform_function |