From 510b61f82bae20b9d8c2b61b51a35d9579c2d347 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 9 Dec 2021 11:00:14 +0000 Subject: [Fix] Output service parts as well --- lualib/lua_mime.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'lualib') diff --git a/lualib/lua_mime.lua b/lualib/lua_mime.lua index 968d38c0a..1646b892c 100644 --- a/lualib/lua_mime.lua +++ b/lualib/lua_mime.lua @@ -609,17 +609,29 @@ exports.message_to_ucl = function(task, stringify_content) local parts = task:get_parts() or E result.parts = {} for _,part in ipairs(parts) do - local l = part:get_length() - if l > 0 then + if not part:is_multipart() and not part:is_message() then local p = { - size = l, + size = part:get_length(), type = string.format('%s/%s', part:get_type()), 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, - boundary = part:get_enclosing_boundary() + boundary = part:get_enclosing_boundary(), } + table.insert(result.parts, p) + else + -- Service part: multipart container or message/rfc822 + local p = { + type = string.format('%s/%s', part:get_type()), + headers = part:get_headers(true) or E, + boundary = part:get_enclosing_boundary(), + } + + if part:is_multipart() then + p.multipart_boundary = part:get_boundary() + end + table.insert(result.parts, p) end end -- cgit v1.2.3