Skip to content

Commit 1289306

Browse files
miss-islingtonserhiy-storchakaclaude
authored
[3.15] gh-68147: Fix RFC references in imaplib (GH-153126) (GH-153130)
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 65b6936 commit 1289306

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
@@ -16,7 +16,7 @@
1616
This module defines three classes, :class:`IMAP4`, :class:`IMAP4_SSL` and
1717
:class:`IMAP4_stream`, which encapsulate a connection to an IMAP4 server and
1818
implement a large subset of the IMAP4rev1 client protocol as defined in
19-
:rfc:`2060`. It is backward compatible with IMAP4 (:rfc:`1730`) servers, but
19+
:rfc:`3501`. It is backward compatible with IMAP4 (:rfc:`1730`) servers, but
2020
note that the ``STATUS`` command is not supported in IMAP4.
2121

2222
.. include:: ../includes/wasm-notavail.rst
@@ -621,7 +621,7 @@ An :class:`IMAP4` instance has the following methods:
621621
.. method:: IMAP4.store(message_set, command, flag_list)
622622

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

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

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

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
@@ -43,8 +43,8 @@
4343
AllowedVersions = ('IMAP4REV1', 'IMAP4') # Most recent first
4444

4545
# Maximal line length when calling readline(). This is to prevent
46-
# reading arbitrary length lines. RFC 3501 and 2060 (IMAP 4rev1)
47-
# don't specify a line length. RFC 2683 suggests limiting client
46+
# reading arbitrary length lines. RFC 3501 (IMAP 4rev1)
47+
# doesn't specify a line length. RFC 2683 suggests limiting client
4848
# command lines to 1000 octets and that servers should be prepared
4949
# to accept command lines up to 8000 octets, so we used to use 10K here.
5050
# 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
@@ -1880,8 +1880,8 @@ def test_connect(self):
18801880
@threading_helper.reap_threads
18811881
def test_bracket_flags(self):
18821882

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

0 commit comments

Comments
 (0)