aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_mime.lua
diff options
context:
space:
mode:
authorJason Stephenson <j.stephenson@live.co.uk>2022-07-15 16:10:45 +0100
committerJason Stephenson <j.stephenson@live.co.uk>2022-07-15 16:10:45 +0100
commitd4979648e9b052f87bc408e3c45b649a6bb54389 (patch)
tree7de1c029e5ddefefcb59c091843d4bfe6febd58c /lualib/lua_mime.lua
parent1aef384f621fee76c72dce0f1d18e825ee7b46fb (diff)
downloadrspamd-d4979648e9b052f87bc408e3c45b649a6bb54389.tar.gz
rspamd-d4979648e9b052f87bc408e3c45b649a6bb54389.zip
[Fix] Empty envelopes should not be emitted as arrays (json+messagepack) when populated envelopes are objects. This greatly complicates decoding in strictly typed languages.
Diffstat (limited to 'lualib/lua_mime.lua')
-rw-r--r--lualib/lua_mime.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/lualib/lua_mime.lua b/lualib/lua_mime.lua
index 4f8450964..575e9152c 100644
--- a/lualib/lua_mime.lua
+++ b/lualib/lua_mime.lua
@@ -596,7 +596,8 @@ exports.message_to_ucl = function(task, stringify_content)
return nil
end
- -- Envelope (smtp) information form email
+
+ -- Envelope (smtp) information from email (nil if empty)
result.envelope = {
from_smtp = (task:get_from('smtp') or E)[1],
recipients_smtp = task:get_recipients('smtp'),
@@ -605,6 +606,9 @@ exports.message_to_ucl = function(task, stringify_content)
client_ip = maybe_stringify_ip(task:get_client_ip()),
from_ip = maybe_stringify_ip(task:get_from_ip()),
}
+ if not next(result.envelope) then
+ result.envelope = nil
+ end
local parts = task:get_parts() or E
result.parts = {}