Skip to content

[3.15] gh-40038: Quote imaplib command arguments when necessary (GH-152703)#153066

Merged
serhiy-storchaka merged 1 commit into
python:3.15from
serhiy-storchaka:backport-600e864-3.15
Jul 5, 2026
Merged

[3.15] gh-40038: Quote imaplib command arguments when necessary (GH-152703)#153066
serhiy-storchaka merged 1 commit into
python:3.15from
serhiy-storchaka:backport-600e864-3.15

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 5, 2026

Copy link
Copy Markdown
Member

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 600e864)

…pythonGH-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.
(cherry picked from commit 600e864)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@read-the-docs-community

Copy link
Copy Markdown

@serhiy-storchaka serhiy-storchaka merged commit 2c99ec4 into python:3.15 Jul 5, 2026
61 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 2c99ec4388f6bc4e09eb095b3caf2e1b4466c108 3.14

@miss-islington-app

Copy link
Copy Markdown

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 2c99ec4388f6bc4e09eb095b3caf2e1b4466c108 3.13

@serhiy-storchaka serhiy-storchaka removed needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jul 5, 2026
@serhiy-storchaka serhiy-storchaka removed their assignment Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant