]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Milter headers: fold before encoding
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 15 Nov 2024 09:00:42 +0000 (09:00 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 15 Nov 2024 09:00:42 +0000 (09:00 +0000)
src/plugins/lua/milter_headers.lua

index 58a227feca792765f27db35881a9c5e41627c176..2daeeed782cdb3add044c6f9342800e1710f31b3 100644 (file)
@@ -213,16 +213,17 @@ local function milter_headers(task)
     if not add[hname] then
       add[hname] = {}
     end
+    local folded = lua_util.fold_header(task, hname, value, stop_chars)
     if rspamd_config:is_mime_utf8() then
-      if not rspamd_util.is_valid_utf8(value) then
-        value = rspamd_util.mime_header_encode(value)
+      if not rspamd_util.is_valid_utf8(folded) then
+        folded = rspamd_util.mime_header_encode(folded)
       end
     else
-      value = rspamd_util.mime_header_encode(value)
+      folded = rspamd_util.mime_header_encode(folded)
     end
     table.insert(add[hname], {
       order = (order or settings.default_headers_order or -1),
-      value = lua_util.fold_header(task, hname, value, stop_chars)
+      value = folded
     })
   end