summaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-11-24 20:45:27 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-11-24 20:45:27 +0000
commitd71ef8ca42ff672bac112a4b89ea0259586d196c (patch)
tree8992ce2f2209aa49304ec4b1c765ca85798c7812 /lualib
parentd7fa89c8b0e4e51e8cd53aa62304343f20bdbd80 (diff)
downloadrspamd-d71ef8ca42ff672bac112a4b89ea0259586d196c.tar.gz
rspamd-d71ef8ca42ff672bac112a4b89ea0259586d196c.zip
[Test] Add unit test for message to ucl function
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_mime.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/lualib/lua_mime.lua b/lualib/lua_mime.lua
index 8100a4f3e..fe82fb717 100644
--- a/lualib/lua_mime.lua
+++ b/lualib/lua_mime.lua
@@ -573,11 +573,14 @@ exports.modify_headers = function(task, hdr_alterations)
end
--[[[
--- @function lua_mime.message_to_ucl(task)
+-- @function lua_mime.message_to_ucl(task, [stringify_content])
-- Exports a message to an ucl object
--]]
-exports.message_to_ucl = function(task)
+exports.message_to_ucl = function(task, stringify_content)
local E = {}
+
+ local maybe_stringify_f = stringify_content and
+ tostring or function(t) return t end
local result = {
size = task:get_size(),
digest = task:get_digest(),
@@ -613,7 +616,7 @@ exports.message_to_ucl = function(task)
type = string.format('%s/%s', part:get_type()),
detected_type = string.format('%s/%s', part:get_detected_type()),
filename = part:get_filename(),
- content = part:get_content(),
+ content = maybe_stringify_f(part:get_content()),
headers = part:get_headers(true) or E,
boundary = part:get_enclosing_boundary()
}