Bug #1191: Net::IMAP.encode_utf7 bug?
http://redmine.ruby-lang.org/issues/show/1191
e$B5/I<<Te(B: Kengo Matsuyama
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
ruby -v: ruby 1.9.2dev (2009-02-22 trunk 22492) [i686-linux]
Net::IMAP.encode_utf7 e$B$K$h$ke(B modified UTF-7
e$B$X$NJQ49$,@5$7$/$J$$$H;W$$$^$9!#e(B
Net::IMAP.encode_utf7(‘e$B$"e(B&’)
=> “&MEIAJg-”
e$B$HJQ49$5$l$^$9$,!"e(BRFC 3501 section 5.1.3 e$B$K=>$&$J$ie(B
“&MEI-&-” e$B$Ke(B
e$BJQ49$5$l$k$N$,@5$7$$$N$G$O$J$$$G$7$g$&$+!#e(B
modified UTF-7 e$B$NB>$N<BAu$,$"$^$j8+IU$+$i$J$+$C$?$N$G$9$,!"e(B
e$B$?$H$($Pe(B PHP e$B$G$Oe(B mb_convert_encoding("e$B$“e(B&”,
“utf7-imap”, “utf8”) e$B$Oe(B
“&MEI-&-” e$B$K$J$j$^$7$?!#e(B(Perl e$B$Ne(B Net::IMAPe$B!"e(BPython
e$B$Ne(B imaplib e$B$G$OL$<BAue(B?)
e$B0J2<$N%Q%C%A$G=$@5$G$-$^$9!#e(B
Index: lib/net/imap.rb
— lib/net/imap.rb (revision 22492)
+++ lib/net/imap.rb (working copy)
@@ -863,7 +863,7 @@
# Encode a string from UTF-8 format to modified UTF-7.
def self.encode_utf7(s)
-
return s.gsub(/(&)|([^\x20-\x25\x27-\x7e]+)/u) {
-
return s.gsub(/(&)|([^\x20-\x7e]+)/u) { if $1 "&-" else