Skip to content

gh-66788: Add the imap4-utf-7 codec#153149

Open
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:imap4-utf7-codec
Open

gh-66788: Add the imap4-utf-7 codec#153149
serhiy-storchaka wants to merge 1 commit into
python:mainfrom
serhiy-storchaka:imap4-utf7-codec

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

Add the imap4-utf-7 codec, implementing the modified UTF-7 encoding used for international IMAP4 mailbox names (RFC 3501, section 5.1.3).

It differs from UTF-7 (RFC 2152):

  • & (not +) is the shift character, and &- encodes a literal &;
  • , is used instead of / in the modified Base64 alphabet;
  • only printable US-ASCII characters (except &) are represented directly, so all other characters, including other controls, are Base64-encoded.

This is the codec dependency of gh-49555 (international mailbox names in imaplib). Automatic encoding/decoding of mailbox names in imaplib itself is a separate question, left for later — modern servers accept raw UTF-8 names via UTF8=ACCEPT (RFC 6855), and auto-conversion has non-trivial API implications.

🤖 Generated with Claude Code

Implement the modified UTF-7 encoding used for international IMAP4
mailbox names (RFC 3501, section 5.1.3).  It differs from UTF-7:
"&" is the shift character ("&-" encodes a literal "&"), "," replaces
"/" in the Base64 alphabet, and all non-printable-ASCII characters are
Base64-encoded.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33450398 | 📁 Comparing 6f44a1b against main (d733b10)

  🔍 Preview build  

3 files changed
± library/codecs.html
± whatsnew/3.16.html
± whatsnew/changelog.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant