aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/milter_headers.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-11 17:48:59 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-11 17:48:59 +0100
commitbc3756f2fd75f286199ad59abb182517930afe38 (patch)
tree8608b216101e491679511c73d4ad25065925d607 /src/plugins/lua/milter_headers.lua
parent5b829f6cf33154f8a41664399a56ce9634fbe3ac (diff)
downloadrspamd-bc3756f2fd75f286199ad59abb182517930afe38.tar.gz
rspamd-bc3756f2fd75f286199ad59abb182517930afe38.zip
[Feature] Allow to insert multiple headers from milter headers
Diffstat (limited to 'src/plugins/lua/milter_headers.lua')
-rw-r--r--src/plugins/lua/milter_headers.lua38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/plugins/lua/milter_headers.lua b/src/plugins/lua/milter_headers.lua
index a1d34f92d..d693e8f7f 100644
--- a/src/plugins/lua/milter_headers.lua
+++ b/src/plugins/lua/milter_headers.lua
@@ -180,13 +180,39 @@ local function milter_headers(task)
local function add_header(name, value, stop_chars, order)
if order then
- add[settings.routines[name].header] = {
- order = order,
- value = lua_util.fold_header(task, name, value, stop_chars)
- }
+ if not add[settings.routines[name].header] then
+ add[settings.routines[name].header] = {
+ order = order,
+ value = lua_util.fold_header(task, name, value, stop_chars)
+ }
+ else
+ if not add[settings.routines[name].header][1] then
+ -- Convert to a table
+ add[settings.routines[name].header] = {
+ [1] = add[settings.routines[name].header]
+ }
+ end
+
+ table.insert(add[settings.routines[name].header], {
+ order = order,
+ value = lua_util.fold_header(task, name, value, stop_chars)
+ })
+ end
else
- add[settings.routines[name].header] = lua_util.fold_header(task, name,
- value, stop_chars)
+ if not add[settings.routines[name].header] then
+ add[settings.routines[name].header] = lua_util.fold_header(task, name,
+ value, stop_chars)
+ else
+ if not add[settings.routines[name].header][1] then
+ -- Convert to a table
+ add[settings.routines[name].header] = {
+ [1] = add[settings.routines[name].header]
+ }
+ end
+
+ table.insert(add[settings.routines[name].header],
+ lua_util.fold_header(task, name, value, stop_chars))
+ end
end
end