whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Handle non-multipart mails
Date Tue, 08 Jan 2019 16:37:52 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 0474119  Handle non-multipart mails
0474119 is described below

commit 04741197882b5d44d8020f5ee03c6c011680f660
Author: Sebb <sebb@apache.org>
AuthorDate: Tue Jan 8 16:37:28 2019 +0000

    Handle non-multipart mails
---
 www/secretary/workbench/views/body.html.rb | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/www/secretary/workbench/views/body.html.rb b/www/secretary/workbench/views/body.html.rb
index e562c9d..e6566ba 100644
--- a/www/secretary/workbench/views/body.html.rb
+++ b/www/secretary/workbench/views/body.html.rb
@@ -58,5 +58,27 @@ _html do
     end
 
     _pre.bg_info body.encode('utf-8', invalid: :replace, undef: :replace)
+  else # must be a non-multipart message
+    body_part = @message.mail.body
+    body = body_part.to_s
+    mime_type = @message.mail.mime_type
+
+    _.comment! "body.encoding=#{body.encoding} body_part.charset=#{body_part.charset} mime_type=#{mime_type}"
+
+    if body.encoding == Encoding::BINARY and body_part.charset
+      body.force_encoding(body_part.charset) rescue nil
+    end
+
+    if mime_type == 'text/plain'
+      _pre.bg_info body.encode('utf-8', invalid: :replace, undef: :replace)
+    elsif mime_type == 'text/html'
+      _div do
+        nodes = _{body.encode('utf-8', invalid: :replace, undef: :replace)}
+
+        fixup_images(nodes)
+      end
+    else
+      _p "(Cannot handle mime-type #{mime_type})"
+    end
   end
 end


Mime
View raw message