sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit db4f651deeae5a8a952c4de2edbeafdb6f402e41
parent 6f1d5f202288ebb71fecb90d4f241b2d3b2d54cb
Author: Gaute Hope <eg@gaute.vetsj.com>
Date:   Sat, 28 Sep 2013 19:40:03 +0200

Fallback to fix_encoding if gsub fails on text in message chunk

Diffstat:
M lib/sup/message_chunks.rb | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/sup/message_chunks.rb b/lib/sup/message_chunks.rb
@@ -125,7 +125,12 @@ EOS
       @lines = nil
       if text
         text = text.transcode(encoded_content.charset || $encoding, text.encoding)
-        @lines = text.gsub("\r\n", "\n").gsub(/\t/, "        ").gsub(/\r/, "").split("\n")
+        begin
+          @lines = text.gsub("\r\n", "\n").gsub(/\t/, "        ").gsub(/\r/, "").split("\n")
+        rescue
+          @lines = text.fix_encoding!.gsub("\r\n", "\n").gsub(/\t/, "        ").gsub(/\r/, "").split("\n")
+        end
+
         @quotable = true
       end
     end