parse_maintainer_name_email returns empty name and wrong email when string has "@" but no angle brackets

オープン 初心者向け
#5,402 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

@pujitha24 がすでに取り組んでいます。

2026年11月1日 から。

  • #5403 @pujitha24 による — オープン
  • #5412 @RohitSutar1823 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend

調査の方向性

バグは src/packagedcode/utils.py 内の parse_maintainer_name_email() 中の has_email チェックにあります。debian.py と pypi.py の呼び出し元がメンテナー文字列を渡しています。issue にある3つの再現例を実行して、現在の出力を確認してください。両方の括弧がない文字列でメールアドレスが返されず、Debian の systemd の例が引き続き解析され、これらのパーサーの既存テストが引き続き通れば完了です。<[email protected] のケースについては、issue の期待値が確認を要する可能性があるため、期待される出力を確認してください。

索引モデルが issue の本文から書いたものです。

説明

bug

parse_maintainer_name_email() in src/packagedcode/utils.py is meant to
split Name <email> strings. It should only extract an email when both <
and > are present. The check is wrong:

has_email = "@" in maintainer and all([
    True
    for char in email_wrappers
    if char in maintainer
])

The list only holds the brackets that are present. If neither bracket is
present it is [], and all([]) is True. If only one is present it is
[True], also True. So any string containing @ is treated as Name <email>.

With no <, maintainer.rpartition("<") returns ('', '', maintainer).
The name becomes an empty string and the whole string is saved as the email.

This affects Debian maintainers and uploaders (debian.py) and
pyproject.toml authors and maintainers (pypi.py).

How To Reproduce
from packagedcode.utils import parse_maintainer_name_email

parse_maintainer_name_email("John Doe [email protected]")
# actual:   ('', 'John Doe [email protected]')
# expected: ('John Doe [email protected]', None)

parse_maintainer_name_email("John Doe <[email protected]")
# actual:   ('John Doe', '[email protected]')
# expected: ('John Doe <[email protected]', None)

parse_maintainer_name_email("Debian systemd Maintainers <[email protected]>")
# works correctly, unchanged
Suggested fix
has_email = "@" in maintainer and all(
    char in maintainer
    for char in email_wrappers
)
主要言語
Python
スター
2.7k
フォーク
848
平均マージ
2日 19時間
マージ済み PR(30日)
8

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

aboutcode-org/scancode-toolkit のほかの issue

aboutcode-org/scancode-toolkit の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。