commit 081c56f: [Project] Use lua_mime to modify headers

Vsevolod Stakhov vsevolod at highsecure.ru
Fri Feb 26 15:35:07 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-02-26 15:21:59 +0000
URL: https://github.com/rspamd/rspamd/commit/081c56fe840308d13d5671837604de722613a2ee

[Project] Use lua_mime to modify headers

---
 src/plugins/lua/arc.lua            | 7 ++++---
 src/plugins/lua/dkim_signing.lua   | 5 +++--
 src/plugins/lua/milter_headers.lua | 8 +++++---
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/plugins/lua/arc.lua b/src/plugins/lua/arc.lua
index fd062ff5c..0e575c5fd 100644
--- a/src/plugins/lua/arc.lua
+++ b/src/plugins/lua/arc.lua
@@ -23,6 +23,7 @@ local rspamd_rsa = require "rspamd_rsa"
 local fun = require "fun"
 local auth_results = require "lua_auth_results"
 local hash = require "rspamd_cryptobox_hash"
+local lua_mime = require "lua_mime"
 
 if confighelp then
   return
@@ -534,12 +535,12 @@ local function arc_sign_seal(task, params, header)
   cur_arc_seal = string.format('%s%s', cur_arc_seal,
     sig:base64(70, nl_type))
 
-  task:set_milter_reply({
-    add_headers = {
+  lua_mime.modify_headers(task, {
+    add = {
       ['ARC-Authentication-Results'] = {order = 1, value = cur_auth_results},
       ['ARC-Message-Signature'] = {order = 1, value = header},
       ['ARC-Seal'] = {order = 1, value = lua_util.fold_header(task,
-        'ARC-Seal', cur_arc_seal) }
+              'ARC-Seal', cur_arc_seal) }
     }
   })
   task:insert_result(settings.sign_symbol, 1.0,
diff --git a/src/plugins/lua/dkim_signing.lua b/src/plugins/lua/dkim_signing.lua
index e42e0f75c..1e5a35be7 100644
--- a/src/plugins/lua/dkim_signing.lua
+++ b/src/plugins/lua/dkim_signing.lua
@@ -19,6 +19,7 @@ local lua_util = require "lua_util"
 local rspamd_logger = require "rspamd_logger"
 local dkim_sign_tools = require "lua_dkim_tools"
 local lua_redis = require "lua_redis"
+local lua_mime = require "lua_mime"
 
 if confighelp then
   return
@@ -55,8 +56,8 @@ local sign_func = rspamd_plugins.dkim.sign
 
 local function insert_sign_results(task, ret, hdr, dkim_params)
   if settings.use_milter_headers then
-    task:set_milter_reply({
-      add_headers = {
+    lua_mime.modify_headers(task, {
+      add = {
         ['DKIM-Signature'] = {order = 1, value = hdr},
       }
     })
diff --git a/src/plugins/lua/milter_headers.lua b/src/plugins/lua/milter_headers.lua
index dd2c27f3c..b65954025 100644
--- a/src/plugins/lua/milter_headers.lua
+++ b/src/plugins/lua/milter_headers.lua
@@ -26,6 +26,7 @@ local util = require "rspamd_util"
 local N = 'milter_headers'
 local lua_util = require "lua_util"
 local lua_maps = require "lua_maps"
+local lua_mime = require "lua_mime"
 local ts = require("tableshape").types
 local E = {}
 
@@ -580,9 +581,10 @@ local function milter_headers(task)
   if not next(add) then add = nil end
   if not next(remove) then remove = nil end
   if add or remove then
-    task:set_milter_reply({
-      add_headers = add,
-      remove_headers = remove
+
+    lua_mime.modify_headers(task, {
+      add = add,
+      remove = remove
     })
   end
 end


More information about the Commits mailing list