Skip to content
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

gh-100991: fix email header References and In-Reply-To being treated as unstructured #128603

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

RanKKI
Copy link
Contributor

@RanKKI RanKKI commented Jan 8, 2025

According to RFC 5322#3.6.4, both References and In-Reply-To are not unstructured fields and should have similar behaviour to Message-ID.

message-id      =   "Message-ID:" msg-id CRLF
in-reply-to     =   "In-Reply-To:" 1*msg-id CRLF
references      =   "References:" 1*msg-id CRLF

Sample Code

msg = textwrap.dedent(f"""\
            Message-ID: <long-but-perfectly-valid-message-id-that-does-not-end-up-qp-encoded@example.com>
            In-Reply-To: <reference-to-long-but-perfectly-valid-message-id-that-gets-qp-encoded@example.com>
            References: <reference-to-long-but-perfectly-valid-message-id-that-gets-qp-encoded@example.com> <reference-to-long-but-perfectly-valid-message-id-that-gets-qp-encoded@example.com>
            """)
msg = email.message_from_string(msg, policy=email.policy.default)

Before this patch

Message-ID: <long-but-perfectly-valid-message-id-that-does-not-end-up-qp-encoded@example.com>
In-Reply-To: =?utf-8?q?=3Creference-to-long-but-perfectly-valid-message-id-t?=
 =?utf-8?q?hat-gets-qp-encoded=40example=2Ecom=3E?=
References: =?utf-8?q?=3Creference-to-long-but-perfectly-valid-message-id-th?=
 =?utf-8?q?at-gets-qp-encoded=40example=2Ecom=3E_=3Creference-to-long-but-pe?=
 =?utf-8?q?rfectly-valid-message-id-that-gets-qp-encoded=40example=2Ecom=3E?=

After this patch

Message-ID: <long-but-perfectly-valid-message-id-that-does-not-end-up-qp-encoded@example.com>
In-Reply-To: <reference-to-long-but-perfectly-valid-message-id-that-gets-qp-encoded@example.com>
References: <reference-to-long-but-perfectly-valid-message-id-that-gets-qp-encoded@example.com>
 <reference-to-long-but-perfectly-valid-message-id-that-gets-qp-encoded@example.com>

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