]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Lua_mime: Allow to add headers in specific order
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 7 Oct 2021 08:45:03 +0000 (09:45 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 7 Oct 2021 08:45:03 +0000 (09:45 +0100)
lualib/lua_mime.lua

index 72190b19e6458572431699ff6f0c11196903773d..ad38d3c32f91087ef732ef26701e8ad3e1dd60b9 100644 (file)
@@ -519,7 +519,8 @@ exports.modify_headers = function(task, hdr_alterations)
   local remove = hdr_alterations.remove or {}
 
   local hdr_flattened = {} -- For C API
-  for hname,hdr in pairs(add) do
+
+  local function flatten_add_header(hname, hdr)
     if not hdr_flattened[hname] then
       hdr_flattened[hname] = {add = {}}
     end
@@ -532,6 +533,17 @@ exports.modify_headers = function(task, hdr_alterations)
       end
     end
   end
+  if hdr_alterations.order then
+    -- Get headers alterations ordered
+    for _,hname in ipairs(hdr_alterations.order) do
+      flatten_add_header(hname, add[hname])
+    end
+  else
+    for hname,hdr in pairs(add) do
+      flatten_add_header(hname, hdr)
+    end
+  end
+
 
   for hname,hdr in pairs(remove) do
     if not hdr_flattened[hname] then