From: Vsevolod Stakhov Date: Fri, 11 May 2018 16:48:59 +0000 (+0100) Subject: [Feature] Allow to insert multiple headers from milter headers X-Git-Tag: 1.7.5~46 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bc3756f2fd75f286199ad59abb182517930afe38;p=rspamd.git [Feature] Allow to insert multiple headers from milter headers --- 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