aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-02-17 17:06:17 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-02-17 17:06:17 +0000
commit3fbf6a9439347238c7e9713686aa811d42e2a7e4 (patch)
treec539d9d883a228824b93d9bebe50337e20558965
parentbfbacbdb444a9fdef2d0a3f7c87a9d6b12f5a2d4 (diff)
downloadrspamd-3fbf6a9439347238c7e9713686aa811d42e2a7e4.tar.gz
rspamd-3fbf6a9439347238c7e9713686aa811d42e2a7e4.zip
[Fix] Lua_mime: Do not perform QP encoding for 7bit parts
-rw-r--r--lualib/lua_mime.lua19
1 files changed, 14 insertions, 5 deletions
diff --git a/lualib/lua_mime.lua b/lualib/lua_mime.lua
index ca61d86f5..9b530a996 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