]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Greylist: Improve body hash calculations 5417/head
authorVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 31 Mar 2025 17:46:30 +0000 (18:46 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Mon, 31 Mar 2025 17:46:30 +0000 (18:46 +0100)
src/plugins/lua/greylist.lua

index e4a633233c52e8a04c7321c3bee6b1054df5d65f..934e17bce034fbb4ab7e1f0363d9a26ec230bd61 100644 (file)
@@ -122,6 +122,29 @@ local function data_key(task)
 
   local h = hash.create()
   h:update(body, len)
+  local subject = task:get_subject() or ''
+  h:update(subject)
+
+  -- Take recipients into account
+  local rcpt = task:get_recipients('smtp')
+  if rcpt then
+    table.sort(rcpt, function(r1, r2)
+      return r1['addr'] < r2['addr']
+    end)
+
+    fun.each(function(r)
+      h:update(r['addr'])
+    end, rcpt)
+  end
+
+  -- Use from as well, but mime one
+  local from = task:get_from('mime')
+
+  local addr = '<>'
+  if from and from[1] then
+    addr = from[1]['addr']
+  end
+  h:update(addr)
 
   local b32 = settings['key_prefix'] .. 'b' .. h:base32():sub(1, 20)
   task:get_mempool():set_variable("grey_bodyhash", b32)