commit 510b61f: [Fix] Output service parts as well

Vsevolod Stakhov vsevolod at highsecure.ru
Thu Dec 9 11:14:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-12-09 11:00:14 +0000
URL: https://github.com/rspamd/rspamd/commit/510b61f82bae20b9d8c2b61b51a35d9579c2d347

[Fix] Output service parts as well

---
 lualib/lua_mime.lua | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

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


More information about the Commits mailing list