aboutsummaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2024-03-28 15:04:57 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2024-03-28 15:04:57 +0000
commit6fe4df00d691cef0a0a4f529c58132669eea7b22 (patch)
tree30e3d44682c54c99d80c84e25c10f09020100dc3 /lualib
parent3737999bbc0f7c5d1db1060abfa788c95c17e99b (diff)
downloadrspamd-6fe4df00d691cef0a0a4f529c58132669eea7b22.tar.gz
rspamd-6fe4df00d691cef0a0a4f529c58132669eea7b22.zip
[Minor] Fix some corner cases
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_scanners/cloudmark.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/lualib/lua_scanners/cloudmark.lua b/lualib/lua_scanners/cloudmark.lua
index 082596688..3768668bb 100644
--- a/lualib/lua_scanners/cloudmark.lua
+++ b/lualib/lua_scanners/cloudmark.lua
@@ -203,8 +203,8 @@ local function table_to_multipart_body(tbl, boundary)
end
local function get_specific_symbol(scores_symbols, score)
- local selected = nil
- local sel_thr = 0
+ local selected
+ local sel_thr = -1
for threshold, sym in pairs(scores_symbols) do
if sel_thr < threshold and threshold <= score then
@@ -223,6 +223,8 @@ assert(get_specific_symbol({ [90] = 'CLOUDMARK_SPAM', [80] = 'CLOUDMARK_SPAM2' }
assert(get_specific_symbol({ [90] = 'CLOUDMARK_SPAM', [80] = 'CLOUDMARK_SPAM2' }, 70) == nil)
assert(get_specific_symbol({ [90] = 'CLOUDMARK_SPAM', [80] = 'CLOUDMARK_SPAM2' }, 90) == 'CLOUDMARK_SPAM')
assert(get_specific_symbol({ }, 80) == nil)
+assert(get_specific_symbol({ [100] = 'CLOUDMARK_SPAM' }, 100) == 'CLOUDMARK_SPAM')
+assert(get_specific_symbol({ [0] = 'CLOUDMARK_SPAM' }, 0) == 'CLOUDMARK_SPAM')
local function parse_cloudmark_reply(task, rule, body)
local parser = ucl.parser()