mailbox.mbox malformed 'From ' lines not being detected/handled
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
mailbox.mbox (class mbox) builds the table of contents (_generate_toc() ) by matching on lines starting with b'From '.
This is RFC compliant, however, malicious emails/senders will sometimes intentionally break this causing unexpected behavior.
I suggest this be considered a bug as :
- In these cases it is not possible to ask the sender to fix their MTA but we still need to parse the message
- There are cases where good senders do this by mistake - e.g. poor line wrapping in quoted-printable content
- Many common end-user email programs gracefully handle this scenario already
I propose exposing a custom 'From ' line delimiter with existing behavior maintained as a default :
diff of mailbox.py :
847c847
< def __init__(self, path, factory=None, create=True, fromline=b'From '):
---
> def __init__(self, path, factory=None, create=True):
850d849
< self._fromline = fromline
865c864
< if line.startswith(self._fromline):
---
> if line.startswith(b'From '):
There are more sophisticated methods which could be explored; for example is_from() function in mutt, or a regex over a byte array.
Your environment
python 3.9.13
Linked PRs
- gh-131415
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
mailbox.py、特に mbox.init と _generate_toc() から始め、変更を加える前にリンクされた PR gh-131415 を確認してください。既存のデフォルト動作を変更せずに、不正な形式の 'From ' 区切り文字を処理できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 30/100