aboutsummaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-08-02 21:12:38 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-08-02 21:12:38 +0100
commit2249d428bd8f27d8e952233c4a15a75f69b12316 (patch)
tree9fa330f3dbc3661b0044c493cef5a431d8836f16 /lualib
parentc16f8e10a928e91f3b0b643bfebdaa2f90b4f521 (diff)
downloadrspamd-2249d428bd8f27d8e952233c4a15a75f69b12316.tar.gz
rspamd-2249d428bd8f27d8e952233c4a15a75f69b12316.zip
[Fix] Adjust length of the fuzzy checks for short text parts
Reported by: @citrin
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_fuzzy.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/lualib/lua_fuzzy.lua b/lualib/lua_fuzzy.lua
index 1f82752f9..ce4ac55ee 100644
--- a/lualib/lua_fuzzy.lua
+++ b/lualib/lua_fuzzy.lua
@@ -126,7 +126,11 @@ local function check_length(task, part, rule)
local adjusted_bytes = bytes
if part:is_text() then
- bytes = part:get_text():get_length()
+ -- Fuzzy plugin uses stripped utf content to get an exact hash, that
+ -- corresponds to `get_content_oneline()`
+ -- However, in the case of empty parts this method returns `nil`, so extra
+ -- sanity check is required.
+ bytes = #(part:get_text():get_content_oneline() or '')
if rule.text_multiplier then
adjusted_bytes = bytes * rule.text_multiplier
end