email: unquoted apostrophe in a MIME parameter value is dropped under policy.default
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
With policy.default a parameter value containing an unquoted apostrophe is not returned, while compat32 returns it. The apostrophe is not a tspecial (RFC 2045), so a bare value such as filename=O'Brien.pdf is a valid token and should be parsed whole.
import email, email.policy
msg = email.message_from_string(
"Content-Disposition: attachment; filename=O'Brien.pdf\n\nbody\n",
policy=email.policy.default
)
msg.get_filename() is None
True
Under email.policy.compat32 the same string returns "O'Brien.pdf". Quoting the value (filename="O'Brien.pdf") works under both policies.
For a multipart message an unquoted apostrophe in the boundary is not recognized, so is_multipart() returns False and the message is not split.
ASPECIALS in Lib/email/_header_value_parser.py includes "'" unconditionally, which terminates the value.
Observed on 3.16.0a0.
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
- gh-153842
- gh-153846
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Lib/email/_header_value_parser.py から始めます。ここでは、issue が ASPECIALS をパラメーター値の終端として特定しています。Content-Disposition のファイル名と multipart boundary における、引用符で囲まれていないアポストロフィについて回帰テストを追加し、その後、関連する email parser のテストを実行して、両方のケースが policy.default で動作することを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100