aboutsummaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-04-13 17:33:19 +0600
committerGitHub <noreply@github.com>2024-04-13 17:33:19 +0600
commit5dce4c98e6ed4d95a031de5789ca055a6fd64880 (patch)
tree3f2ea213f8076c5b45fafa68918fda7f2fd2569a /lualib
parent48583c49818cbd06b977c9fc1b23949699f364d1 (diff)
parentf824108f9ea930d46dff216dcd5ecb1a7bf1c6b6 (diff)
downloadrspamd-5dce4c98e6ed4d95a031de5789ca055a6fd64880.tar.gz
rspamd-5dce4c98e6ed4d95a031de5789ca055a6fd64880.zip
Merge pull request #4924 from fatalbanana/cmae_scores
[Minor] Cloudmark scores_symbols: convert keys to numeric values
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_scanners/cloudmark.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/lualib/lua_scanners/cloudmark.lua b/lualib/lua_scanners/cloudmark.lua
index 3768668bb..cb55a3bbf 100644
--- a/lualib/lua_scanners/cloudmark.lua
+++ b/lualib/lua_scanners/cloudmark.lua
@@ -89,6 +89,20 @@ local function cloudmark_preload(rule, cfg, ev_base, _)
})
end
+local function numerify(d)
+ local l = {}
+ for k in pairs(d) do
+ table.insert(l, k)
+ end
+ for _, k in ipairs(l) do
+ local new_key = tonumber(k)
+ if new_key then
+ d[new_key] = d[k]
+ d[k] = nil
+ end
+ end
+end
+
local function cloudmark_config(opts)
local cloudmark_conf = {
@@ -116,6 +130,10 @@ local function cloudmark_config(opts)
cloudmark_conf = lua_util.override_defaults(cloudmark_conf, opts)
+ if type(cloudmark_conf.scores_symbols) == 'table' then
+ numerify(cloudmark_conf.scores_symbols)
+ end
+
if not cloudmark_conf.prefix then
cloudmark_conf.prefix = 'rs_' .. cloudmark_conf.name .. '_'
end