commit 05c186a: [Minor] Consider subject when checking hash function input length

Vsevolod Stakhov vsevolod at rspamd.com
Tue Aug 2 20:21:04 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-08-02 21:17:20 +0100
URL: https://github.com/rspamd/rspamd/commit/05c186a485f9b07680f6cb1d0e44039a37a400bf (HEAD -> master)

[Minor] Consider subject when checking hash function input length

---
 lualib/lua_fuzzy.lua | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lualib/lua_fuzzy.lua b/lualib/lua_fuzzy.lua
index ce4ac55ee..332e828ac 100644
--- a/lualib/lua_fuzzy.lua
+++ b/lualib/lua_fuzzy.lua
@@ -131,6 +131,13 @@ local function check_length(task, part, rule)
       -- 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 '')
+
+      -- Short hashing algorithm also use subject unless explicitly denied
+      if not rule.no_subject then
+        local subject = task:get_subject() or ''
+        bytes = bytes + #subject
+      end
+
       if rule.text_multiplier then
         adjusted_bytes = bytes * rule.text_multiplier
       end


More information about the Commits mailing list