commit 3fbf6a9: [Fix] Lua_mime: Do not perform QP encoding for 7bit parts

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Feb 17 17:07:08 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-02-17 17:06:17 +0000
URL: https://github.com/rspamd/rspamd/commit/3fbf6a9439347238c7e9713686aa811d42e2a7e4 (HEAD -> master)

[Fix] Lua_mime: Do not perform QP encoding for 7bit parts

---
 lualib/lua_mime.lua | 19 ++++++++++++++-----
 1 file 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


More information about the Commits mailing list