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

未关闭 适合新手
#5,402 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

@pujitha24 已经在做这个了。

开始于 2026年11月1日。

  • #5403 来自 @pujitha24 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

错误位于 src/packagedcode/utils.py 中 parse_maintainer_name_email() 内的 has_email 检查。debian.py 和 pypi.py 中的调用方会传入维护者字符串。运行 issue 中的三个复现示例以查看当前输出。完成标准是:缺少两个括号的字符串不返回任何邮箱,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
派生
831
平均合并
3 天 4 小时
30 天内合并 PR
7

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

aboutcode-org/scancode-toolkit 的其他 Issue

查看 aboutcode-org/scancode-toolkit 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。