@@ -491,7 +491,7 @@ module Net
491
491
#
492
492
# ==== RFC6855: <tt>UTF8=ACCEPT</tt>, <tt>UTF8=ONLY</tt>
493
493
#
494
- # - See #enable for information about support foi UTF-8 string encoding.
494
+ # - See #enable for information about support for UTF-8 string encoding.
495
495
#
496
496
#--
497
497
# ==== RFC7888: <tt>LITERAL+</tt>, +LITERAL-+
@@ -1931,20 +1931,14 @@ def uid_thread(algorithm, search_keys, charset)
1931
1931
# UTF-7}[::decode_utf7] for mailbox names, or RFC2047 encoded-words for
1932
1932
# message headers.
1933
1933
#
1934
- # *Note:* For now, strings with 8-bit characters are still _sent_ using
1935
- # "literal" syntax. A future update will change how commands send UTF-8
1936
- # strings when <tt>UTF8=ACCEPT</tt> is enabled. This update should be
1937
- # backward-compatible.
1938
- #
1939
1934
# *Note:* <em>A future update may set string encodings slightly
1940
1935
# differently</em>, e.g: "US-ASCII" when UTF-8 is not enabled, and "UTF-8"
1941
1936
# when it is. Currently, the encoding of strings sent as "quoted" or
1942
- # "text" will _always_ be "UTF-8", even when a 7-bit encoding is used
1943
- # (e.g. UTF-7, encoded-words, quoted-printable, base64). And currently,
1944
- # string "literals" sent by the server will always have an "ASCII-8BIT"
1945
- # (binary) encoding, even if they must contain UTF-8 data---although a
1946
- # server _should_ use "quoted" strings once <tt>UTF8=ACCEPT</tt> is
1947
- # enabled.
1937
+ # "text" will _always_ be "UTF-8", even when only ASCII characters are
1938
+ # used (e.g. "Subject: Agenda") And currently, string "literals" sent
1939
+ # by the server will always have an "ASCII-8BIT" (binary)
1940
+ # encoding, even if they generally contain UTF-8 data, if they are
1941
+ # text at all.
1948
1942
#
1949
1943
# [<tt>"UTF8=ONLY"</tt> [RFC6855[https://tools.ietf.org/html/rfc6855]]]
1950
1944
#
@@ -1974,7 +1968,10 @@ def enable(*capabilities)
1974
1968
. join ( ' ' )
1975
1969
synchronize do
1976
1970
send_command ( "ENABLE #{ capabilities } " )
1977
- return @responses . delete ( "ENABLED" ) [ -1 ]
1971
+ result = @responses . delete ( "ENABLED" ) [ -1 ]
1972
+ @utf8_strings ||= result . include? "UTF8=ACCEPT"
1973
+ @utf8_strings ||= result . include? "IMAP4REV2"
1974
+ result
1978
1975
end
1979
1976
end
1980
1977
@@ -2222,6 +2219,7 @@ def initialize(host, port_or_options = {},
2222
2219
@port = options [ :port ] || ( options [ :ssl ] ? SSL_PORT : PORT )
2223
2220
@tag_prefix = "RUBY"
2224
2221
@tagno = 0
2222
+ @utf8_strings = false
2225
2223
@open_timeout = options [ :open_timeout ] || 30
2226
2224
@idle_response_timeout = options [ :idle_response_timeout ] || 5
2227
2225
@parser = ResponseParser . new
0 commit comments