public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
[RSPAMD] Add boundary if present when applying domain-wide footer
8d7235b5
data/conf/rspamd/lua/rspamd.local.lua | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
Diff
diff --git a/data/conf/rspamd/lua/rspamd.local.lua b/data/conf/rspamd/lua/rspamd.local.lua
index 2bf328e5..9d0a58bc 100644
--- a/data/conf/rspamd/lua/rspamd.local.lua
+++ b/data/conf/rspamd/lua/rspamd.local.lua
@@ -550,13 +550,13 @@ rspamd_config:register_symbol({
-- determine newline type
local function newline(task)
local t = task:get_newlines_type()
-
+
if t == 'cr' then
return '\r'
elseif t == 'lf' then
return '\n'
end
-
+
return '\r\n'
end
-- retrieve footer
@@ -564,7 +564,7 @@ rspamd_config:register_symbol({
if err or type(data) ~= 'string' then
rspamd_logger.infox(rspamd_config, "domain wide footer request for user %s returned invalid or empty data (\"%s\") or error (\"%s\")", uname, data, err)
else
-
+
-- parse json string
local footer = cjson.decode(data)
if not footer then
@@ -613,26 +613,30 @@ rspamd_config:register_symbol({
if footer.plain and footer.plain ~= "" then
footer.plain = lua_util.jinja_template(footer.plain, replacements, true)
end
-
+
-- add footer
local out = {}
local rewrite = lua_mime.add_text_footer(task, footer.html, footer.plain) or {}
-
+
local seen_cte
local newline_s = newline(task)
-
+
local function rewrite_ct_cb(name, hdr)
if rewrite.need_rewrite_ct then
if name:lower() == 'content-type' then
- local nct = string.format('%s: %s/%s; charset=utf-8',
- 'Content-Type', rewrite.new_ct.type, rewrite.new_ct.subtype)
+ -- include boundary if present
+ local boundary_part = rewrite.new_ct.boundary and
+ string.format('; boundary="%s"', rewrite.new_ct.boundary) or ''
+ local nct = string.format('%s: %s/%s; charset=utf-8%s',
+ 'Content-Type', rewrite.new_ct.type, rewrite.new_ct.subtype, boundary_part)
out[#out + 1] = nct
- -- update Content-Type header
+ -- update Content-Type header (include boundary if present)
task:set_milter_reply({
remove_headers = {['Content-Type'] = 0},
})
task:set_milter_reply({
- add_headers = {['Content-Type'] = string.format('%s/%s; charset=utf-8', rewrite.new_ct.type, rewrite.new_ct.subtype)}
+ add_headers = {['Content-Type'] = string.format('%s/%s; charset=utf-8%s',
+ rewrite.new_ct.type, rewrite.new_ct.subtype, boundary_part)}
})
return
elseif name:lower() == 'content-transfer-encoding' then
@@ -651,16 +655,16 @@ rspamd_config:register_symbol({
end
out[#out + 1] = hdr.raw:gsub('\r?\n?$', '')
end
-
+
task:headers_foreach(rewrite_ct_cb, {full = true})
-
+
if not seen_cte and rewrite.need_rewrite_ct then
out[#out + 1] = string.format('%s: %s', 'Content-Transfer-Encoding', 'quoted-printable')
end
-
+
-- End of headers
out[#out + 1] = newline_s
-
+
if rewrite.out then
for _,o in ipairs(rewrite.out) do
out[#out + 1] = o