Skip to content

fix: allow @, +, and Unicode branch names#1022

Open
Lubrsy706 wants to merge 2 commits intoanthropics:mainfrom
Lubrsy706:fix/branch-name-validation-unicode-and-at
Open

fix: allow @, +, and Unicode branch names#1022
Lubrsy706 wants to merge 2 commits intoanthropics:mainfrom
Lubrsy706:fix/branch-name-validation-unicode-and-at

Conversation

@Lubrsy706
Copy link
Copy Markdown

@Lubrsy706 Lubrsy706 commented Mar 6, 2026

Summary

Fixes #998 and #1020

The whitelist regex in validateBranchName (src/github/operations/branch.ts) previously rejected valid git branch names containing @, +, or non-ASCII Unicode characters.

Changes

  • update src/github/operations/branch.ts to allow @, +, and Unicode letters/numbers in branch names
  • keep rejecting Git-reserved patterns like @{, .lock, .., consecutive /, and invalid ref characters
  • extend test/validate-branch-name.test.ts with coverage for + alongside the existing @ and Unicode cases

Security

The @{ reflog syntax is still rejected explicitly. Control characters, shell metacharacters, and Git-special characters like ~, ^, :, ?, *, [, ], and \ remain blocked. The validator still forbids names that could trigger option injection or path traversal.

Test plan

  • bun test test/validate-branch-name.test.ts
  • bun run typecheck

@Lubrsy706
Copy link
Copy Markdown
Author

Friendly ping: this PR has been ready for review since March 6, 2026. If there is anything blocking it or if you would prefer changes before merge, let me know and I can update it. Would appreciate a review when someone has time.

@Lubrsy706 Lubrsy706 changed the title fix: allow @ and Unicode letters in branch name validation fix: allow @, +, and Unicode branch names Mar 24, 2026
@Lubrsy706
Copy link
Copy Markdown
Author

Updated this PR to include + as well. Git accepts branch names like feature+x, so the validator now allows @, +, and Unicode branch names while still rejecting reserved/unsafe patterns like @{, .lock, .., and invalid ref characters. I also added test coverage for the + case and reran the branch-name tests plus typecheck.

@Lubrsy706
Copy link
Copy Markdown
Author

Following up on this PR. The branch-name handling change should be ready for review; please let me know if you'd like any updates or additional test coverage from my side.

Lubrsy706 and others added 2 commits April 7, 2026 20:49
Update the whitelist regex in validateBranchName to support:
- `@` character (anthropics#998): valid in git branch names, only `@{` is reserved
  (already checked separately)
- Unicode letters via `\p{L}` (anthropics#1020): enables non-ASCII branch names
  like Japanese, Chinese, Cyrillic characters

Fixes anthropics#998
Fixes anthropics#1020

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Lubrsy706 Lubrsy706 force-pushed the fix/branch-name-validation-unicode-and-at branch from e6978c5 to 2fe35e5 Compare April 7, 2026 14:30
@Lubrsy706
Copy link
Copy Markdown
Author

Rebased this branch onto the latest main and resolved the merge conflicts. The branch-name validation changes now include #, @, +, and Unicode support together, and I reran bun test test/validate-branch-name.test.ts after the rebase. PR should now be conflict-free and ready for review.

@Lubrsy706
Copy link
Copy Markdown
Author

Following up on this PR. The branch-name handling fix should be ready for review; if you would like any adjustments or broader coverage for special-character branch names, I can update it. Would appreciate a review when someone has time.

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.

Branch name validation rejects @ character which is valid in git

1 participant