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

email module incorrectly qp-encodes References and In-Reply-To headers #100991

Open
mricon opened this issue Jan 12, 2023 · 0 comments
Open

email module incorrectly qp-encodes References and In-Reply-To headers #100991

mricon opened this issue Jan 12, 2023 · 0 comments
Labels
topic-email type-bug An unexpected behavior, bug, or error

Comments

@mricon
Copy link

mricon commented Jan 12, 2023

Bug report

import email
import email.policy

msg = email.message.EmailMessage()
msg['Message-Id'] = '<long-but-perfectly-valid-message-id-that-does-not-end-up-qp-encoded@example.com>'
msg['References'] = '<reference-to-long-but-perfectly-valid-message-id-that-gets-qp-encoded@example.com>'
msg['In-Reply-To'] = '<reference-to-long-but-perfectly-valid-message-id-that-gets-qp-encoded@example.com>'
msg.set_payload('No body')

bdata = msg.as_bytes(policy=email.policy.SMTP)
print(bdata.decode())

Expected output:

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

No body

Actual output:

Message-Id: <long-but-perfectly-valid-message-id-that-does-not-end-up-qp-encoded@example.com>
References: =?utf-8?q?=3Creference-to-long-but-perfectly-valid-message-id-th?=
 =?utf-8?q?at-gets-qp-encoded=40example=2Ecom=3E?=
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?=

No body

Your environment

  • CPython versions tested on: 3.11.1
  • Operating system and architecture: Fedora 37 x86_64
@mricon mricon added the type-bug An unexpected behavior, bug, or error label Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-email type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants