]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.15] gh-40038: Quote imaplib command arguments when necessary (GH-152703) (GH-153066)
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 5 Jul 2026 06:55:59 +0000 (09:55 +0300)
committerGitHub <noreply@github.com>
Sun, 5 Jul 2026 06:55:59 +0000 (06:55 +0000)
commit2c99ec4388f6bc4e09eb095b3caf2e1b4466c108
treeddb5087d4cc5195605d037573f0a2a8fdfd1924b
parent7eb476dfbe8a62b02f976ab3211d86e8729c8f91
[3.15] gh-40038: Quote imaplib command arguments when necessary (GH-152703) (GH-153066)

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]