parse_maintainer_name_email returns empty name and wrong email when string has "@" but no angle brackets
维护者通常 3 天内回复
评估
调研方向
错误位于 src/packagedcode/utils.py 中 parse_maintainer_name_email() 内的 has_email 检查。debian.py 和 pypi.py 中的调用方会传入维护者字符串。运行 issue 中的三个复现示例以查看当前输出。完成标准是:缺少两个括号的字符串不返回任何邮箱,Debian systemd 示例仍能正确解析,并且这些解析器的现有测试仍然通过。请核实 <[email protected] 这一情况的预期输出,因为 issue 中的预期结果可能需要确认。
由索引模型根据 Issue 内容生成。
描述
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
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
aboutcode-org/scancode-toolkit 的其他 Issue
-
bug: Unreachable JSON extension and format validation in validate_input_path可能已有人在做 @0Cymantek0 于 20 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
aboutcode-org/scancode-toolkit#5351 · 1 条评论 ·
维护者通常 3 天内回复
-
CycloneDX output: metadata.properties[].value emits JSON array instead of string可能已有人在做 @0Cymantek0 于 20 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
aboutcode-org/scancode-toolkit#5349 · 1 条评论 ·
维护者通常 3 天内回复
-
Duplicate 'COPYLEFT' entries in legal file classification names in legal.py and classify.py可能已有人在做 @Pradeepbeleri 于 47 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
aboutcode-org/scancode-toolkit#5319 · 2 条评论 ·
维护者通常 3 天内回复
-
Duplicate autogen.sh entry in commoncode default ignores可能已有人在做 @Daksha1611 于 50 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 92/100
aboutcode-org/scancode-toolkit#5316 ·
维护者通常 3 天内回复
-
Duplicate LGPL key in rubygems LICENSES_MAPPING makes one mapping unreachable可能已有人在做 @Daksha1611 于 50 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
aboutcode-org/scancode-toolkit#5314 · 1 条评论 ·
维护者通常 3 天内回复
查看 aboutcode-org/scancode-toolkit 的全部 Issue
相似的 Issue
-
predict_file with crop_model duplicates predictions once per image可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
weecology/DeepForest#1445 ·
-
agent-ready priority: medium status: ready
难度 2/5 1-3 小时 新手友好度 68/100
melodic-software/claude-code-plugins#11864 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
PolicyEngine/policyengine-uk#2785 ·
维护者通常 2 天内回复
-
correction metadata
难度 1/5 1 小时以内 新手友好度 62/100
acl-org/acl-anthology#10724 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
use-agent-os/agent-os#3739 ·
维护者通常 1 天内回复