sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 7ecb464b8ab72c21eb4be5759fd90bd8103cd0a5
parent f4a6a49e6fbce293b88cf39f3e65077c6e32c121
Author: Gaute Hope <eg@gaute.vetsj.com>
Date:   Thu,  9 Sep 2010 13:48:49 +0200

Force UTF-8 on label and contact completion

Fix issue 36, by forcing UTF-8 encoding on string that will be matched.

Only if the force_encoding method is available to maintain 1.8
compatability.

There is likely to still be a few other places where the equivilent of
this bug still exists.

Also force encoding on label search completion

UTF-8 label completion: Convert existing labels

Diffstat:
M lib/sup/buffer.rb | 4 ++++
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
@@ -453,6 +453,7 @@ EOS
 
   def ask_with_completions domain, question, completions, default=nil
     ask domain, question, default do |s|
+      s.force_encoding 'UTF-8' if s.methods.include?(:encoding)
       completions.select { |x| x =~ /^#{Regexp::escape s}/i }.map { |x| [x, x] }
     end
   end
@@ -469,6 +470,8 @@ EOS
           raise "william screwed up completion: #{partial.inspect}"
         end
 
+      prefix.force_encoding 'UTF-8' if prefix.methods.include?(:encoding)
+      target.force_encoding 'UTF-8' if target.methods.include?(:encoding)
       completions.select { |x| x =~ /^#{Regexp::escape target}/i }.map { |x| [prefix + x, x] }
     end
   end
@@ -477,6 +480,7 @@ EOS
     ask domain, question, default do |partial|
       prefix, target = partial.split_on_commas_with_remainder
       target ||= prefix.pop || ""
+      target.force_encoding 'UTF-8' if target.methods.include?(:encoding)
       prefix = prefix.join(", ") + (prefix.empty? ? "" : ", ")
       completions.select { |x| x =~ /^#{Regexp::escape target}/i }.sort_by { |c| [ContactManager.contact_for(c) ? 0 : 1, c] }.map { |x| [prefix + x, x] }
     end