Infinite loop in `email._header_value_parser._fold_mime_parameters` when parameter names are too long
未关闭
还没有人认领这个 Issue。
stdlib
topic-email
type-bug
type-security
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- PR 合并指标
- PR 指标待抓取
描述
Bug report
Bug description:
Tested with 3.6 and 3.13.1
>>> import email.message
>>> message = email.message.EmailMessage()
...
>>> message.add_attachment('Hello World!', filename='hello.txt', params={130 * 'A': 'too long parameter name'})
None
>>> message.defects
[]
>>> message
<email.message.EmailMessage object at 0x7fe78ec74ec0>
>>> message.as_string()
130 characters for a media type parameter name is (a bit) more than https://datatracker.ietf.org/doc/html/rfc6838#section-4.3 allows but I didn't expect it to lead into an infinite loop. I wanted to check if the email module would catch that defect, which apparently it doesn't.
Distribution is openSUSE Leap 15.6, python 3.13.1 was installed from pyenv, 3.6 is from the distribution. The python3.11 binary from the distribution exhibits the same behaviour.
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
- gh-138226
- gh-138227
- gh-138231
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用 email.message.EmailMessage.add_attachment 和一个 130 个字符的参数名重现该问题,然后检查 email._header_value_parser._fold_mime_parameters。在继续之前,查看相关 issue 的讨论和链接的 PRs。输入不再无限循环,并且回归测试覆盖验证了产生的行为,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100