]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-40038: Quote imaplib command arguments when necessary (GH-152703)
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 5 Jul 2026 06:12:58 +0000 (09:12 +0300)
committerGitHub <noreply@github.com>
Sun, 5 Jul 2026 06:12:58 +0000 (09:12 +0300)
commit600e86490fddf4732e8b993058ca011cc6387464
treece5369218c3ab3c17187ec9356704a0d00679afb
parent5616505b443b13d9f5766dedcf6c0b43167705b6
gh-40038: Quote imaplib command arguments when necessary (GH-152703)

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.

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]