ruby-changes:15582
From: shugo <ko1@a...>
Date: Sun, 25 Apr 2010 21:46:38 +0900 (JST)
Subject: [ruby-changes:15582] Ruby:r27487 (ruby_1_8): * lib/net/imap (encode_utf7): encode & properly. Thanks, Kengo
shugo 2010-04-25 21:42:10 +0900 (Sun, 25 Apr 2010) New Revision: 27487 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27487 Log: * lib/net/imap (encode_utf7): encode & properly. Thanks, Kengo Matsuyama. [ruby-dev:38063] backported from trunk. Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/lib/net/imap.rb branches/ruby_1_8/test/net/imap/test_imap.rb Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 27486) +++ ruby_1_8/ChangeLog (revision 27487) @@ -1,3 +1,8 @@ +Sun Apr 25 21:36:41 2010 Shugo Maeda <shugo@r...> + + * lib/net/imap (encode_utf7): encode & properly. Thanks, Kengo + Matsuyama. [ruby-dev:38063] backported from trunk. + Sat Apr 24 13:06:57 2010 Nobuyoshi Nakada <nobu@r...> * ruby.c (get_arglen): skip the last terminator of argv before Index: ruby_1_8/lib/net/imap.rb =================================================================== --- ruby_1_8/lib/net/imap.rb (revision 27486) +++ ruby_1_8/lib/net/imap.rb (revision 27487) @@ -851,7 +851,7 @@ # 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-\x7e]+)/u) { |x| if $1 "&-" else Index: ruby_1_8/test/net/imap/test_imap.rb =================================================================== --- ruby_1_8/test/net/imap/test_imap.rb (revision 27486) +++ ruby_1_8/test/net/imap/test_imap.rb (revision 27487) @@ -45,4 +45,20 @@ server.close end end + + def test_encode_utf7 + utf8 = "\357\274\241\357\274\242\357\274\243" + s = Net::IMAP.encode_utf7(utf8) + assert_equal("&,yH,Iv8j-", s) + + utf8 = "\343\201\202&" + s = Net::IMAP.encode_utf7(utf8) + assert_equal("&MEI-&-", s) + end + + def test_decode_utf7 + s = Net::IMAP.decode_utf7("&,yH,Iv8j-") + utf8 = "\357\274\241\357\274\242\357\274\243" + assert_equal(utf8, s) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/