]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix some corner cases 4894/head
authorVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 28 Mar 2024 15:04:57 +0000 (15:04 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 28 Mar 2024 15:04:57 +0000 (15:04 +0000)
lualib/lua_scanners/cloudmark.lua

index 08259668879a8153f522c60b095ff0cee356274b..3768668bb77f2dba42d3666d5fdd036f3a1ba241 100644 (file)
@@ -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()