email.message generates invalid encoded header
未关闭
还没有人认领这个 Issue。
stdlib
topic-email
type-bug
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- PR 合并指标
- PR 指标待抓取
描述
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
- gh-136098
- gh-136099
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先使用 SMTP policy 和 email.message.Message 重现该示例,并检查 header folding 和 RFC 2047 encoding path。完成的标准是生成的 Subject 不包含空的 encoded-text,且仍然 RFC 2047-valid,并为此输入提供回归覆盖;报告列出关联的 PRs gh-136098 和 gh-136099。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100