summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-25 12:42:10 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-25 12:42:10 +0000
commit1b9012049d5d115abdcd93e2c31948e1141080c4 (patch)
treef002da31ee933e4602c88e52f092f2b7c9cc1f15
parent720160f364fb8412ebbd20c9185f6c1124890d8b (diff)
* lib/net/imap (encode_utf7): encode & properly. Thanks, Kengo
Matsuyama. [ruby-dev:38063] backported from trunk. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@27487 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/net/imap.rb2
-rw-r--r--test/net/imap/test_imap.rb16
3 files changed, 22 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index e4651794fe..ef70e78d75 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Apr 25 21:36:41 2010 Shugo Maeda <[email protected]>
+
+ * 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 <[email protected]>
* ruby.c (get_arglen): skip the last terminator of argv before
diff --git a/lib/net/imap.rb b/lib/net/imap.rb
index 663be7fc84..4430aa85dc 100644
--- a/lib/net/imap.rb
+++ b/lib/net/imap.rb
@@ -851,7 +851,7 @@ module Net
# 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
diff --git a/test/net/imap/test_imap.rb b/test/net/imap/test_imap.rb
index 147fb4ae2d..45d41781c7 100644
--- a/test/net/imap/test_imap.rb
+++ b/test/net/imap/test_imap.rb
@@ -45,4 +45,20 @@ class IMAPTest < Test::Unit::TestCase
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