From: Vsevolod Stakhov Date: Mon, 17 Feb 2020 17:06:17 +0000 (+0000) Subject: [Fix] Lua_mime: Do not perform QP encoding for 7bit parts X-Git-Tag: 2.4~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3fbf6a9439347238c7e9713686aa811d42e2a7e4;p=thirdparty%2Frspamd.git [Fix] Lua_mime: Do not perform QP encoding for 7bit parts --- diff --git a/lualib/lua_mime.lua b/lualib/lua_mime.lua index ca61d86f58..9b530a996e 100644 --- a/lualib/lua_mime.lua +++ b/lualib/lua_mime.lua @@ -20,6 +20,7 @@ limitations under the License. --]] local rspamd_util = require "rspamd_util" +local rspamd_text = require "rspamd_text" local exports = {} @@ -63,8 +64,19 @@ exports.add_text_footer = function(task, html_footer, text_footer) ct = 'text/html' end + local encode_func = function(input) + return rspamd_util.encode_qp(input, 80, task:get_newlines_type()) + end + if part:get_cte() == '7bit' then cte = '7bit' + encode_func = function(input) + if type(input) == 'userdata' then + return input + else + return rspamd_text.fromstring(input) + end + end end if is_multipart then @@ -82,13 +94,11 @@ exports.add_text_footer = function(task, html_footer, text_footer) content = string.format('%s%s', content:sub(-(#newline_s), #newline_s + 1), -- content without last newline footer) - out[#out + 1] = {rspamd_util.encode_qp(content, - 80, task:get_newlines_type()), true} + out[#out + 1] = {encode_func(content), true} out[#out + 1] = '' else content = content .. footer - out[#out + 1] = {rspamd_util.encode_qp(content, - 80, task:get_newlines_type()), true} + out[#out + 1] = {encode_func(content), true} out[#out + 1] = '' end @@ -140,7 +150,6 @@ exports.add_text_footer = function(task, html_footer, text_footer) local boundaries = {} local cur_boundary - for _,part in ipairs(task:get_parts()) do local boundary = part:get_boundary() if part:is_multipart() then