Skip to content

GH-78319: Stop sending the UTF8 marker when appending messages #107290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

arnt
Copy link

@arnt arnt commented Jul 26, 2023

The UTF8 marker is defined in RFC 6855 and tells the server that the message being appended contains UTF8 addresses, an unencoded UTF8 subject, etc. However, if a client appends a message containing UTF8 addresses but without that marker, the bytes can only be parsed as UTF8 because that's the only RFC-compliant way to parse those bytes.

RFC 6855 says clients MUST send the UTF8 marker.

Due to an accidental discrepancy, RFC 9051 (IMAP4rev2) does not contain that marker. IMAP4rev2 was intended to be upwardly compatible with RFC 6855, but this problem broke that. This has no ill effects, since the marker does not change the message's meaning.

While investigating the problem, I noticed that Python uses the marker incorrectly: Python uses it to mark ALL messages if UTF8=ACCEPT support has been enabled, not just ones that contain UTF8 addresses.

The best way forward appear to be using the syntax defined in RFC 9051 and publishing a revision to RFC 6855, so this change modifies imaplib to match RFC 9051.

FWIW JMAP is like IMAP4rev2 in this case; UTF8 is just there, without any marker. Also, neither UTF8=ACCEPT, IMAP4rev2 or JMAP provide any way to learn whether a message was stored with or without the marker.

This quasi-accidentally solves #78319 by removing the case that broke.

…to a mailbox.

The UTF8 marker is defined in RFC 6855 and tells the server that the
message being appended contains UTF8 addresses, an unencoded UTF8 subject,
etc.  However, if a client appends a message containing UTF8 addresses but
without that marker, the bytes can only be parsed as UTF8 because that's
the only RFC-compliant way to parse those bytes.

RFC 6855 says clients MUST send the UTF8 marker.

Due to an accidental discrepancy, RFC 9051 (IMAP4rev2) does not contain
that marker. IMAP4rev2 was intended to be upwardly compatible with RFC
6855, but this problem broke that. This has no ill effects, since the
marker does not change the message's meaning.

While investigating the problem, I noticed that Python uses the marker
incorrectly: Python uses it to mark ALL messages if UTF8=ACCEPT support
has been enabled, not just ones that contain UTF8 addresses.

The best way forward appear to be using the syntax defined in RFC 9051 and
publishing a revision to RFC 6855, so this change modifies imaplib to
match RFC 9051.

FWIW JMAP is like IMAP4rev2 in this case; UTF8 is just there, without any
marker. Also, neither UTF8=ACCEPT, IMAP4rev2 or JMAP provide any way to
learn whether a message was stored with or without the marker.

This quasi-accidentally solves python#78319 by removing the case that broke.
@arnt arnt requested a review from a team as a code owner July 26, 2023 11:25
@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@arnt
Copy link
Author

arnt commented Jul 26, 2023

This seems small enough to not require a NEWS entry, I'd say.

@arnt
Copy link
Author

arnt commented Jul 26, 2023

I submitted the internet-draft to supersede RFC 6855 now and expect to get it to RFC fairly quickly.

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.

2 participants