email.message generates invalid encoded header
未關閉
還沒有人認領這個 Issue。
stdlib
topic-email
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- 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