Skip to content

fix: allow @ and Unicode letters in branch name validation#1022

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

fix: allow @ and Unicode letters in branch name validation#1022
Lubrsy706 wants to merge 1 commit intoanthropics:mainfrom
Lubrsy706:fix/branch-name-validation-unicode-and-at

Conversation

@Lubrsy706
Copy link

Summary

Fixes #998 and #1020

The whitelist regex in validateBranchName (src/github/operations/branch.ts) only allowed ASCII alphanumeric characters, rejecting valid git branch names containing @ or non-ASCII Unicode characters.

Changes

  • src/github/operations/branch.ts: Updated the whitelist regex from /^[a-zA-Z0-9][a-zA-Z0-9/_.-]*$/ to /^[\p{L}\p{N}][\p{L}\p{N}/_.\-@]*$/u to allow:
    • @ character — valid in git, only @{ is reserved (already checked separately on line 104)
    • Unicode letters (\p{L}) — enables non-ASCII branch names like feat/add-機能追加
  • test/validate-branch-name.test.ts: Added test cases for @ in branch names and non-ASCII Unicode characters (Japanese, Chinese, Cyrillic)

Security

The @{ reflog syntax is still rejected by the existing check on line 104. Control characters, shell metacharacters, and git-special characters (~^:?*[]\) are still blocked by the earlier check on line 55. The u flag enables Unicode-aware matching without introducing new attack vectors.

Test plan

  • All 32 existing + new tests pass (bun test test/validate-branch-name.test.ts)
  • New tests cover: TICKET-123@add-feature, user@branch, feat/add-機能追加, 修复/bug-123, фича/новая

🤖 Generated with Claude Code

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>
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