commit af23c1f: [Minor] Lua_mime: Flatten headers array
Vsevolod Stakhov
vsevolod at highsecure.ru
Sat Nov 27 15:00:04 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-11-27 14:21:08 +0000
URL: https://github.com/rspamd/rspamd/commit/af23c1f6783d569e16121db98ba7a3c9ff23f799
[Minor] Lua_mime: Flatten headers array
---
lualib/lua_mime.lua | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/lualib/lua_mime.lua b/lualib/lua_mime.lua
index fe82fb717..f248dec7a 100644
--- a/lualib/lua_mime.lua
+++ b/lualib/lua_mime.lua
@@ -579,13 +579,26 @@ end
exports.message_to_ucl = function(task, stringify_content)
local E = {}
+ local function flatten_headers(hdrs)
+ local res = {}
+
+ for _,e in ipairs(hdrs) do
+ if type(e) == 'table' and e[1] then
+ for _,h in ipairs(e) do table.insert(res, h) end
+ else
+ table.insert(res, e)
+ end
+ end
+
+ return res
+ end
local maybe_stringify_f = stringify_content and
tostring or function(t) return t end
local result = {
size = task:get_size(),
digest = task:get_digest(),
newlines = task:get_newlines_type(),
- headers = task:get_headers(true) or E
+ headers = flatten_headers(task:get_headers(true) or E)
}
-- Utility to convert ip addr to a string or nil if invalid/absent
@@ -617,7 +630,7 @@ exports.message_to_ucl = function(task, stringify_content)
detected_type = string.format('%s/%s', part:get_detected_type()),
filename = part:get_filename(),
content = maybe_stringify_f(part:get_content()),
- headers = part:get_headers(true) or E,
+ headers = flatten_headers(part:get_headers(true) or E),
boundary = part:get_enclosing_boundary()
}
table.insert(result.parts, p)
More information about the Commits
mailing list