From 101b8021a09eed4bdd5047c3dd1d4bc447ffddad Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 2 Jun 2022 21:23:12 +0100 Subject: [PATCH] [Fix] Properly parse expressions atoms Issue: #4181 --- lualib/lua_maps_expressions.lua | 2 +- src/plugins/lua/force_actions.lua | 2 +- src/plugins/lua/multimap.lua | 2 +- src/plugins/lua/settings.lua | 10 +++++++--- src/plugins/lua/spamassassin.lua | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lualib/lua_maps_expressions.lua b/lualib/lua_maps_expressions.lua index 6a2532bf4..0d030b4c4 100644 --- a/lualib/lua_maps_expressions.lua +++ b/lualib/lua_maps_expressions.lua @@ -174,7 +174,7 @@ local function create(cfg, obj, module_name) -- Now process and parse expression local function parse_atom(str) local atom = table.concat(fun.totable(fun.take_while(function(c) - if string.find(', \t()><+!|&\n', c) then + if string.find(', \t()><+!|&\n', c, 1, true) then return false end return true diff --git a/src/plugins/lua/force_actions.lua b/src/plugins/lua/force_actions.lua index 4704b849b..c0c023fae 100644 --- a/src/plugins/lua/force_actions.lua +++ b/src/plugins/lua/force_actions.lua @@ -38,7 +38,7 @@ local function gen_cb(params) local function parse_atom(str) local atom = table.concat(fun.totable(fun.take_while(function(c) - if string.find(', \t()><+!|&\n', c) then + if string.find(', \t()><+!|&\n', c, 1, true) then return false end return true diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index edc54443d..31891fc6a 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -1195,7 +1195,7 @@ local function add_multimap_rule(key, newrule) local function parse_atom(str) local atom = table.concat(fun.totable(fun.take_while(function(c) - if string.find(', \t()><+!|&\n', c) then + if string.find(', \t()><+!|&\n', c, 1, true) then return false end return true diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua index ead8ced8e..94e1b2327 100644 --- a/src/plugins/lua/settings.lua +++ b/src/plugins/lua/settings.lua @@ -848,7 +848,7 @@ local function process_settings_table(tbl, allow_ids, mempool, is_static) if not checks[safe_key] then checks[safe_key] = cond - aliases[safe_key] = true + aliases[full_key] = true end return safe_key @@ -943,7 +943,11 @@ local function process_settings_table(tbl, allow_ids, mempool, is_static) -- Count checks and create Rspamd expression from a set of rules local nchecks = 0 - for _,_ in pairs(checks) do nchecks = nchecks + 1 end + for k,_ in pairs(checks) do + if not aliases[k] then + nchecks = nchecks + 1 + end + end if nchecks > 0 then -- Now we can deal with the expression! @@ -970,7 +974,7 @@ local function process_settings_table(tbl, allow_ids, mempool, is_static) -- Parse expression's sanity local function parse_atom(str) local atom = table.concat(fun.totable(fun.take_while(function(c) - if string.find(', \t()><+!|&\n', c) then + if string.find(', \t()><+!|&\n', c, 1, true) then return false end return true diff --git a/src/plugins/lua/spamassassin.lua b/src/plugins/lua/spamassassin.lua index 2e332d198..c98203fb6 100644 --- a/src/plugins/lua/spamassassin.lua +++ b/src/plugins/lua/spamassassin.lua @@ -1170,7 +1170,7 @@ end local function parse_atom(str) local atom = table.concat(fun.totable(fun.take_while(function(c) - if string.find(', \t()><+!|&\n', c) then + if string.find(', \t()><+!|&\n', c, 1, true) then return false end return true -- 2.39.5