fix: parse single-rune Unicode flags - #2434
Open
znnnnnnn-wil wants to merge 1 commit into
Open
znnnnnnn-wil wants to merge 1 commit into
znnnnnnn-wil wants to merge 1 commit into
Conversation
Count Unicode code points when choosing a flag prefix and decode the first flag rune before classifying it as an option. Fixes urfave#2433
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.
What type of PR is this?
What this PR does / why we need it:
-before deciding whether an argument is a flag.Some code and tests were assisted by Codex. I reviewed, understood, and tested the complete change and take responsibility for it.
Which issue(s) this PR fixes:
Fixes #2433
Special notes for your reviewer:
The parsing change only affects non-ASCII input. ASCII arguments decode to the same rune value as the byte previously inspected.
Testing
go test . -run '^TestCommand_SingleRuneUnicodeFlag$' -count=1go test ./... -count=1go run scripts/build.go vetgo run scripts/build.go check-binary-sizego run scripts/build.go generatego run scripts/build.go gfmrungit diff --no-index --ignore-all-space(no differences)The repository's
go run scripts/build.go testcommand requires-race; it could not run on this Windows host because CGO is disabled and no C compiler is installed. The same packages passed without-race, and CI will run the race-enabled suite on supported runners.Release Notes