From e875cfa1fedca6826c55b4d62f6860c933427cf7 Mon Sep 17 00:00:00 2001 From: shugo Date: Sat, 22 Dec 2007 08:00:04 +0000 Subject: * lib/net/imap.rb (encode_utf7): accept UTF-8 strings. * lib/net/imap.rb (decode_utf7): return UTF-8 strings. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/net/imap.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 540e366729..2398a5d10c 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -852,19 +852,19 @@ module Net end base64.unpack("m")[0].unpack("n*").pack("U*") end - } + }.force_encoding("UTF-8") end # Encode a string from UTF-8 format to modified UTF-7. def self.encode_utf7(s) - return s.gsub(/(&)|([^\x20-\x25\x27-\x7e]+)/n) { |x| + return s.gsub(/(&)|([^\x20-\x25\x27-\x7e]+)/u) { |x| if $1 "&-" else base64 = [x.unpack("U*").pack("n*")].pack("m") "&" + base64.delete("=\n").tr("/", ",") + "-" end - } + }.force_encoding("ASCII-8BIT") end private -- cgit v1.2.3