diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-05-11 17:48:59 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-05-11 17:48:59 +0100 |
commit | bc3756f2fd75f286199ad59abb182517930afe38 (patch) | |
tree | 8608b216101e491679511c73d4ad25065925d607 | |
parent | 5b829f6cf33154f8a41664399a56ce9634fbe3ac (diff) | |
download | rspamd-bc3756f2fd75f286199ad59abb182517930afe38.tar.gz rspamd-bc3756f2fd75f286199ad59abb182517930afe38.zip |
[Feature] Allow to insert multiple headers from milter headers
-rw-r--r-- | src/plugins/lua/milter_headers.lua | 38 |
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 |