diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-11-27 14:21:08 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-11-27 14:58:13 +0000 |
commit | af23c1f6783d569e16121db98ba7a3c9ff23f799 (patch) | |
tree | db0c371c21b905b46cdb7332ae06402bfe0a7e81 /lualib/lua_mime.lua | |
parent | b213023538a0d55b4895eb1b13b5396d9cd8f555 (diff) | |
download | rspamd-af23c1f6783d569e16121db98ba7a3c9ff23f799.tar.gz rspamd-af23c1f6783d569e16121db98ba7a3c9ff23f799.zip |
[Minor] Lua_mime: Flatten headers array
Diffstat (limited to 'lualib/lua_mime.lua')
-rw-r--r-- | lualib/lua_mime.lua | 17 |
1 files 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) |