Skip to content

Commit 7a11c23

Browse files
miss-islingtonserhiy-storchakaclaude
authored
[3.14] gh-68147: Fix RFC references in imaplib (GH-153126) (GH-153131)
Refer to RFC 3501, which obsoleted RFC 2060. "]" is disallowed in flags, not in tags. (cherry picked from commit 74a2438) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 27075bf commit 7a11c23

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

Doc/library/imaplib.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
This module defines three classes, :class:`IMAP4`, :class:`IMAP4_SSL` and
2525
:class:`IMAP4_stream`, which encapsulate a connection to an IMAP4 server and
2626
implement a large subset of the IMAP4rev1 client protocol as defined in
27-
:rfc:`2060`. It is backward compatible with IMAP4 (:rfc:`1730`) servers, but
27+
:rfc:`3501`. It is backward compatible with IMAP4 (:rfc:`1730`) servers, but
2828
note that the ``STATUS`` command is not supported in IMAP4.
2929

3030
.. include:: ../includes/wasm-notavail.rst
@@ -629,7 +629,7 @@ An :class:`IMAP4` instance has the following methods:
629629
.. method:: IMAP4.store(message_set, command, flag_list)
630630

631631
Alters flag dispositions for messages in mailbox. *command* is specified by
632-
section 6.4.6 of :rfc:`2060` as being one of "FLAGS", "+FLAGS", or "-FLAGS",
632+
section 6.4.6 of :rfc:`3501` as being one of "FLAGS", "+FLAGS", or "-FLAGS",
633633
optionally with a suffix of ".SILENT".
634634

635635
For example, to set the delete flag on all messages::
@@ -643,11 +643,11 @@ An :class:`IMAP4` instance has the following methods:
643643

644644
Creating flags containing ']' (for example: "[test]") violates
645645
:rfc:`3501` (the IMAP protocol). However, imaplib has historically
646-
allowed creation of such tags, and popular IMAP servers, such as Gmail,
646+
allowed creation of such flags, and popular IMAP servers, such as Gmail,
647647
accept and produce such flags. There are non-Python programs which also
648-
create such tags. Although it is an RFC violation and IMAP clients and
648+
create such flags. Although it is an RFC violation and IMAP clients and
649649
servers are supposed to be strict, imaplib still continues to allow
650-
such tags to be created for backward compatibility reasons, and as of
650+
such flags to be created for backward compatibility reasons, and as of
651651
Python 3.6, handles them if they are sent from the server, since this
652652
improves real-world compatibility.
653653

Lib/imaplib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""IMAP4 client.
22
3-
Based on RFC 2060.
3+
Based on RFC 3501.
44
55
Public class: IMAP4
66
Public variable: Debug
@@ -45,8 +45,8 @@
4545
AllowedVersions = ('IMAP4REV1', 'IMAP4') # Most recent first
4646

4747
# Maximal line length when calling readline(). This is to prevent
48-
# reading arbitrary length lines. RFC 3501 and 2060 (IMAP 4rev1)
49-
# don't specify a line length. RFC 2683 suggests limiting client
48+
# reading arbitrary length lines. RFC 3501 (IMAP 4rev1)
49+
# doesn't specify a line length. RFC 2683 suggests limiting client
5050
# command lines to 1000 octets and that servers should be prepared
5151
# to accept command lines up to 8000 octets, so we used to use 10K here.
5252
# In the modern world (eg: gmail) the response to, for example, a

Lib/test/test_imaplib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,8 +1858,8 @@ def test_connect(self):
18581858
@threading_helper.reap_threads
18591859
def test_bracket_flags(self):
18601860

1861-
# This violates RFC 3501, which disallows ']' characters in tag names,
1862-
# but imaplib has allowed producing such tags forever, other programs
1861+
# This violates RFC 3501, which disallows ']' characters in flags,
1862+
# but imaplib has allowed producing such flags forever, other programs
18631863
# also produce them (eg: OtherInbox's Organizer app as of 20140716),
18641864
# and Gmail, for example, accepts them and produces them. So we
18651865
# support them. See issue #21815.

0 commit comments

Comments
 (0)