[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sup-devel] Bug: UTF-8 error when sending messages



Excerpts from Adeel Ahmad Khan's message of 2011-01-29 04:11:40 +0100:
> When sending a message containing certain characters, like guillemets
> <http://en.wikipedia.org/wiki/Guillemets>, I experiencing the following error.
> 
>     --- ArgumentError from thread: main
>     invalid byte sequence in UTF-8
>     /usr/lib/ruby/gems/1.9.1/gems/sup-0.12.1/lib/sup/modes/edit-message-mode.rb:497:in `block in mentions_attachments?'

Could you try if this patch fixes it (or just edit the lines manually) ?

- Gaute


From 67a8777875091da6ae57c762f18254509f418a46 Mon Sep 17 00:00:00 2001
From: Gaute Hope <eg@gaute.vetsj.com>
Date: Sun, 30 Jan 2011 16:57:15 +0100
Subject: [PATCH] Attempt to handle encoding errors when searching for attachment string

---
 lib/sup/modes/edit-message-mode.rb |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
index 734a879..8517011 100644
--- a/lib/sup/modes/edit-message-mode.rb
+++ b/lib/sup/modes/edit-message-mode.rb
@@ -494,7 +494,10 @@ private
     if HookManager.enabled? "mentions-attachments"
       HookManager.run "mentions-attachments", :header => @header, :body => @body
     else
-      @body.any? {  |l| l =~ /^[^>]/ && l =~ /\battach(ment|ed|ing|)\b/i }
+      @body.any? {  |l|
+        l.force_encoding 'UTF-8' if l.methods.include?(:encoding)
+        l =~ /^[^>]/ && l =~ /\battach(ment|ed|ing|)\b/i
+      }
     end
   end
 
-- 
1.7.3.5