whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: attempt to use the indicated encoding
Date Wed, 20 Jun 2018 02:58:10 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys 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 cb0b690  attempt to use the indicated encoding
cb0b690 is described below

commit cb0b6905457d4c3e1f12b5cd4ffecb6249d6f2d8
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Tue Jun 19 19:57:56 2018 -0700

    attempt to use the indicated encoding
---
 www/board/agenda/views/actions/posted-reports.json.rb | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/www/board/agenda/views/actions/posted-reports.json.rb b/www/board/agenda/views/actions/posted-reports.json.rb
index b00efa7..3a9b866 100755
--- a/www/board/agenda/views/actions/posted-reports.json.rb
+++ b/www/board/agenda/views/actions/posted-reports.json.rb
@@ -14,7 +14,14 @@ ARCHIVE = '/srv/mail/board'
 if @path and @path =~ /^\d+\/\w+$/
   mail = Mail.new(File.read(File.join(ARCHIVE, @path)))
   if mail.text_part
-    return {text: mail.text_part.body.to_s.force_encoding(Encoding::UTF_8)}
+    begin
+      text = mail.text_part.body.to_s.force_encoding(mail.text_part.charset)
+    rescue
+      text = mail.text_part.body.to_s.force_encoding(Encoding::UTF_8)
+    end
+      
+    return {text: text.encode('UTF-8', invalid: :replace, undef: :replace)}
+
   else
     return {text: ''}
   end


Mime
View raw message