-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Open
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtopic-emailtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
A message header generated by email.message.Message
can contain invalid RFC 2047 encoded-words.
import sys
from email.message import Message
from email.policy import SMTP
msg = Message(policy=SMTP)
msg["Subject"] = "Re: some few filler words here RE: Routeraustausch und übriggebliebene Glasfaser"
sys.stdout.buffer.write(msg.as_bytes())
Result:
Subject: Re: some few filler words here RE: Routeraustausch und =?utf-8?q??=
=?utf-8?q?=C3=BCbriggebliebene?= Glasfaser
The encoded-word in the first line is invalid. Per RFC 2047 the "encoded-text" must not be empty:
encoded-word = "=?" charset "?" encoding "?" encoded-text "?="
encoded-text = 1*<Any printable ASCII character other than "?"
or SPACE>
The error does not appear in this case with the default
policy because the header value is split up entirely differently.
CPython versions tested on:
3.13, 3.12
Operating systems tested on:
Windows, Other
Linked PRs
LamentXU123
Metadata
Metadata
Assignees
Labels
stdlibPython modules in the Lib dirPython modules in the Lib dirtopic-emailtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error