From: Vsevolod Stakhov Date: Thu, 28 Mar 2024 15:04:57 +0000 (+0000) Subject: [Minor] Fix some corner cases X-Git-Tag: 3.9.0~81^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F4894%2Fhead;p=rspamd.git [Minor] Fix some corner cases --- 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()