fix: allow @ and Unicode letters in branch name validation#1022
Open
Lubrsy706 wants to merge 1 commit intoanthropics:mainfrom
Open
fix: allow @ and Unicode letters in branch name validation#1022Lubrsy706 wants to merge 1 commit intoanthropics:mainfrom
Lubrsy706 wants to merge 1 commit intoanthropics:mainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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}/_.\-@]*$/uto allow:@character — valid in git, only@{is reserved (already checked separately on line 104)\p{L}) — enables non-ASCII branch names likefeat/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. Theuflag enables Unicode-aware matching without introducing new attack vectors.Test plan
bun test test/validate-branch-name.test.ts)TICKET-123@add-feature,user@branch,feat/add-機能追加,修复/bug-123,фича/новая🤖 Generated with Claude Code