Skip to content

fix(diffs): handle quoted git diff headers#736

Merged
amadeus merged 1 commit into
mainfrom
amadeus/parse-patch-fix
May 22, 2026
Merged

fix(diffs): handle quoted git diff headers#736
amadeus merged 1 commit into
mainfrom
amadeus/parse-patch-fix

Conversation

@amadeus
Copy link
Copy Markdown
Member

@amadeus amadeus commented May 22, 2026

Git can emit quoted diff headers for escaped non-ASCII paths, such as diff --git "a/..." "b/...". The parser regex accepted this form, but the capture destructuring only read the unquoted capture slots, causing name to be undefined and crashing on .trim().

Select the quoted or unquoted capture groups explicitly, fail softly for invalid git diff headers, and add regression coverage for quoted escaped file names.

A bug that was exposed by this PR: vercel/next.js#93247

Git can emit quoted diff headers for escaped non-ASCII paths, such as
`diff --git "a/..." "b/..."`. The parser regex accepted this form, but
the capture destructuring only read the unquoted capture slots, causing
`name` to be undefined and crashing on `.trim()`.

Select the quoted or unquoted capture groups explicitly, fail softly for
invalid git diff headers, and add regression coverage for quoted escaped
file names.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pierre-docs-diffshub Ready Ready Preview May 22, 2026 7:51pm
pierre-docs-trees Ready Ready Preview May 22, 2026 7:51pm
pierrejs-diff-demo Ready Ready Preview May 22, 2026 7:51pm
pierrejs-docs Ready Ready Preview May 22, 2026 7:51pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant