]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Rework and fix headers addition
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 14 May 2018 09:44:53 +0000 (10:44 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 14 May 2018 09:45:38 +0000 (10:45 +0100)
src/plugins/lua/milter_headers.lua

index 73b268b2e02af5c1e8bff4bf5dbd7ea06e99d105..fb2d20db82a33fd41aac86fc76db745cd551d18a 100644 (file)
@@ -182,39 +182,39 @@ local function milter_headers(task)
   local routines, common, add, remove = {}, {}, {}, {}
 
   local function add_header(name, value, stop_chars, order)
+    local hname = settings.routines[name].header
     if order then
-      if not add[settings.routines[name].header] then
-        add[settings.routines[name].header] = {
+      if not add[hname] then
+        add[hname] = {
           order = order,
-          value = lua_util.fold_header(task, name, value, stop_chars)
+          value = lua_util.fold_header(task, hname, value, stop_chars)
         }
       else
-        if not add[settings.routines[name].header][1] then
+        if not add[hname][1] then
           -- Convert to a table
-          add[settings.routines[name].header] = {
-            [1] = add[settings.routines[name].header]
+          add[hname] = {
+            [1] = add[hname]
           }
         end
 
-        table.insert(add[settings.routines[name].header], {
+        table.insert(add[hname], {
           order = order,
-          value = lua_util.fold_header(task, name, value, stop_chars)
+          value = lua_util.fold_header(task, hname, value, stop_chars)
         })
       end
     else
-      if not add[settings.routines[name].header] then
-        add[settings.routines[name].header] = lua_util.fold_header(task, name,
-            value, stop_chars)
+      if not add[hname] then
+        add[hname] = lua_util.fold_header(task, hname, value, stop_chars)
       else
-        if not add[settings.routines[name].header][1] then
+        if not add[hname][1] then
           -- Convert to a table
-          add[settings.routines[name].header] = {
-            [1] = add[settings.routines[name].header]
+          add[hname] = {
+            [1] = add[hname]
           }
         end
 
-        table.insert(add[settings.routines[name].header],
-            lua_util.fold_header(task, name, value, stop_chars))
+        table.insert(add[hname],
+            lua_util.fold_header(task, hname, value, stop_chars))
       end
     end
   end
@@ -470,7 +470,7 @@ local function milter_headers(task)
 
     if res and #res > 0 then
       for _,h in ipairs(res) do
-        add_header(add[settings.routines['fuzzy-hashes'].header], h)
+        add_header('fuzzy-hashes', h)
       end
     end
   end