Skip to content

Commit 4f479ac

Browse files
miss-islingtonserhiy-storchakaclaude
authored
[3.13] gh-68147: Fix RFC references in imaplib (GH-153126) (GH-153132)
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 5fd2493 commit 4f479ac

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

2929
.. include:: ../includes/wasm-notavail.rst
@@ -541,7 +541,7 @@ An :class:`IMAP4` instance has the following methods:
541541
.. method:: IMAP4.store(message_set, command, flag_list)
542542

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

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

556556
Creating flags containing ']' (for example: "[test]") violates
557557
:rfc:`3501` (the IMAP protocol). However, imaplib has historically
558-
allowed creation of such tags, and popular IMAP servers, such as Gmail,
558+
allowed creation of such flags, and popular IMAP servers, such as Gmail,
559559
accept and produce such flags. There are non-Python programs which also
560-
create such tags. Although it is an RFC violation and IMAP clients and
560+
create such flags. Although it is an RFC violation and IMAP clients and
561561
servers are supposed to be strict, imaplib still continues to allow
562-
such tags to be created for backward compatibility reasons, and as of
562+
such flags to be created for backward compatibility reasons, and as of
563563
Python 3.6, handles them if they are sent from the server, since this
564564
improves real-world compatibility.
565565

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

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

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

0 commit comments

Comments
 (0)