Git.commit: --author value is wrapped in literal double quotes, corrupting author names that contain a quote character

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

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
冷清
技术栈
git, typescript
领域
tooling

调研方向

从 Git.commit 的实现开始,找到组装 --author 参数的位置,然后检查现有的提交相关测试。使用包含双引号的 committer 名称重现问题,移除参数外围的字面引号,并添加一个回归测试,检查 git log -1 --format='%an' 是否保留完整名称。

由索引模型根据 Issue 内容生成。

描述

bug S3

Observed behavior

Git.commit builds the --author argument with literal double quotes:

args.push(`--author="${committer.name} <${committer.email}>"`);

Because child_process.spawn is used without a shell, the literal " characters are part of the value passed to git. Git's "crud stripping" of identity strings hides the problem for ordinary names (leading/trailing quotes get filtered out), but the protection breaks down if committer.name itself contains a ".

Expected behavior

The literal quotes should not be in the value. The standard format that git documents is just --author=Name <email>, with no surrounding quotes.

Minimal reproduction

await git.commit('msg', {
  committer: { name: 'Joe \"Real\"', email: '[email protected]' },
});
// git log -1 --format='%an'
// -> Joe \"Real           (the trailing quote is silently lost)

Verified with a standalone Node script that replicates Git.commit's exact spawn arguments. Observed result:

AN=[Joe \"Real] AE=[[email protected]] CN=[Joe \"Real] CE=[[email protected]]

The trailing \" from the source name is gone.

Suggested fix

args.push(`--author=${committer.name} <${committer.email}>`);

A regression test that commits with committer.name = 'Joe \"Real\"' and asserts git log -1 --format='%an' returns Joe \"Real\" would catch this.

主要语言
TypeScript
星标
2
派生
1
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

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

joewalker/loop-the-loop 的其他 Issue

查看 joewalker/loop-the-loop 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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