]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-40038: Quote imaplib command arguments when necessary (GH-152703) (GH-153069)
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 5 Jul 2026 07:36:11 +0000 (10:36 +0300)
committerGitHub <noreply@github.com>
Sun, 5 Jul 2026 07:36:11 +0000 (07:36 +0000)
commit03d090972a368cbac89acff5ed2a63bdba14dff7
tree801f09617cef42ce40dda8fb030f966e274ddefb
parent07efb08123ba9367a7107325adb9d5626dca1ca9
[3.14] gh-40038: Quote imaplib command arguments when necessary (GH-152703) (GH-153069)

Argument quoting was inadvertently disabled when imaplib was ported to
Python 3 (bpo-1210 commented out the ``_checkquote()`` call, bpo-9638
then removed it), so since Python 3.0 commands failed for arguments
containing protocol-sensitive characters, such as a space in a mailbox
name.

Quoting is restored and reimplemented per the RFC 3501 grammar, so that
arguments that need quoting are escaped and quoted, while flags, sequence
sets and list wildcards are left intact.

For backward compatibility, an argument already enclosed in double quotes
is left unchanged, so code that quotes arguments itself keeps working.
(cherry picked from commit 600e86490fddf4732e8b993058ca011cc6387464)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Doc/library/imaplib.rst
Lib/imaplib.py
Lib/test/test_imaplib.py
Misc/NEWS.d/next/Library/2026-06-30-12-00-00.gh-issue-40038.qK7mGv.rst [new file with mode: 0644]