diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-03-10 15:43:01 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-03-13 15:19:13 +0000 |
commit | 149e4cccf34eaa6edefe91565d0295d7f45faf82 (patch) | |
tree | d5d03a4f2af250a98ab96b7447d05ff3c64292b7 /lualib/lua_maps.lua | |
parent | 69f265d68cf9e7067e7e3d0e8cc80e1679013731 (diff) | |
download | rspamd-149e4cccf34eaa6edefe91565d0295d7f45faf82.tar.gz rspamd-149e4cccf34eaa6edefe91565d0295d7f45faf82.zip |
[Fix] Fix parsing of maps definitions
Diffstat (limited to 'lualib/lua_maps.lua')
-rw-r--r-- | lualib/lua_maps.lua | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua index d3573100a..a67e11b63 100644 --- a/lualib/lua_maps.lua +++ b/lualib/lua_maps.lua @@ -294,6 +294,11 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback) end if opt[1] then + local function check_plain_map(line) + return lua_util.str_startswith('http', line) + or lua_util.str_startswith('file:', line) + or lua_util.str_startswith('/', line) + end -- Adjust each element if needed local adjusted for i, source in ipairs(opt) do @@ -311,6 +316,7 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback) if mtype == 'radix' then if string.find(opt[1], '^%d') then + -- List of numeric stuff (hope it's ipnets definitions) local map = rspamd_config:radix_from_ucl(opt) if map then @@ -338,7 +344,7 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback) end end elseif mtype == 'regexp' or mtype == 'glob' then - if string.find(opt[1], '^/%a') or string.find(opt[1], '^http') then + if check_plain_map(opt[1]) then -- Plain table local map = rspamd_config:add_map { type = mtype, @@ -372,7 +378,8 @@ local function rspamd_map_add_from_ucl(opt, mtype, description, callback) end end else - if string.find(opt[1], '^/%a') or string.find(opt[1], '^http') then + -- Not regexp/glob + if check_plain_map(opt[1]) then -- Plain table local map = rspamd_config:add_map { type = mtype, |