diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-07-23 18:02:16 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-07-23 18:02:16 +0100 |
commit | 2393156481374420919438468e2eda7725607635 (patch) | |
tree | b0b3914bf651ecb9736bfc4ac1a7c7d4f8e0399d /lualib | |
parent | 0de3deeadb49872e4b2eecf74faa2741d45a2bab (diff) | |
download | rspamd-2393156481374420919438468e2eda7725607635.tar.gz rspamd-2393156481374420919438468e2eda7725607635.zip |
[Minor] Lua_selectors: Allow to index numeric arrays in selectors
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_selectors.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua index efe332878..c123ae637 100644 --- a/lualib/lua_selectors.lua +++ b/lualib/lua_selectors.lua @@ -1027,8 +1027,12 @@ exports.parse_selector = function(cfg, str) if proc_name:match('^__') then -- Special case - method local method_name = proc_name:match('^__(.*)$') + -- Check array indexing... + if tonumber(method_name) then + method_name = tonumber(method_name) + end local processor = { - name = method_name, + name = tostring(method_name), method = true, args = proc_tbl[2] or E, types = { @@ -1052,7 +1056,7 @@ exports.parse_selector = function(cfg, str) if not transform_function[proc_name] then logger.errx(cfg, 'processor %s is unknown', proc_name) - pipeline_error = true + pipeline_error = proc_name return nil end local processor = lua_util.shallowcopy(transform_function[proc_name]) @@ -1060,7 +1064,7 @@ exports.parse_selector = function(cfg, str) processor.args = proc_tbl[2] or E if not check_args(processor.name, processor.args_schema, processor.args) then - pipeline_error = true + pipeline_error = 'args schema for ' .. proc_name return nil end @@ -1071,7 +1075,7 @@ exports.parse_selector = function(cfg, str) end, fun.tail(sel)) if pipeline_error then - logger.errx(cfg, 'unknown or invalid processor used, exiting') + logger.errx(cfg, 'unknown or invalid processor used: "%s", exiting', pipeline_error) return nil end |