Repository navigation
fix brace alternation scanning with character classes - #115
Merged
Merged
Conversation
Character classes within a brace alternation (such as {[}],a}) were not
skipped when scanning for the next alternative or the matching closing
brace, so commas and braces inside the class were treated as alternation
syntax. ValidatePattern blessed these patterns, but Match could never
match them. Skip character classes in indexNextAlt and
indexMatchedClosingAlt, matching what the validator already does.
sidsri14
marked this pull request as draft
August 27, 2026 10:26
Owner
|
Looks like a good fix to me... I made some changes to your tests so that they'll actually run on-disk (ie, exercise Glob). |
Sirherobrine23
pushed a commit
to Sirherobrine23/gitea-runner
that referenced
this pull request
Sep 28, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | Type | Update | |---|---|---|---|---|---| | [github.com/bmatcuk/doublestar/v4](https://github.com/bmatcuk/doublestar) | `v4.10.0` → `v4.10.2` |  |  | require | patch | | [github.com/ulikunitz/xz](https://github.com/ulikunitz/xz) | `v0.5.16` → `v0.5.17` |  |  | | patch | | nginx | `62ff208` → `df221db` | | | | digest | --- ### Release Notes <details> <summary>bmatcuk/doublestar (github.com/bmatcuk/doublestar/v4)</summary> ### [`v4.10.2`](https://github.com/bmatcuk/doublestar/releases/tag/v4.10.2): Better support for Windows "Junctions" [Compare Source](bmatcuk/doublestar@v4.10.1...v4.10.2) Has improved support for reading "junctions" in Windows (ie, Windows' version of symlinks). Thanks [@​x0Lazarus](https://github.com/x0Lazarus) for the PR! #### What's Changed - Fix Windows junction traversal with Go 1.23 and later by [@​x0Lazarus](https://github.com/x0Lazarus) in [#​117](bmatcuk/doublestar#117) #### New Contributors - [@​x0Lazarus](https://github.com/x0Lazarus) made their first contribution in [#​117](bmatcuk/doublestar#117) **Full Changelog**: <bmatcuk/doublestar@v4.10.1...v4.10.2> ### [`v4.10.1`](https://github.com/bmatcuk/doublestar/releases/tag/v4.10.1): Fixed issue with alternatives and character classes [Compare Source](bmatcuk/doublestar@v4.10.0...v4.10.1) There was an issue where commas or ending curly brackets inside a character class would cause code looking for the next alternative (commas) or the end of alternatives (ending curly brackets) to erroneously match those characters inside the character classes. Thanks to [@​sidsri14](https://github.com/sidsri14) for the fix! #### What's Changed - fix brace alternation scanning with character classes by [@​sidsri14](https://github.com/sidsri14) in [#​115](bmatcuk/doublestar#115) #### New Contributors - [@​sidsri14](https://github.com/sidsri14) made their first contribution in [#​115](bmatcuk/doublestar#115) **Full Changelog**: <bmatcuk/doublestar@v4.10.0...v4.10.1> </details> <details> <summary>ulikunitz/xz (github.com/ulikunitz/xz)</summary> ### [`v0.5.17`](ulikunitz/xz@v0.5.16...v0.5.17) [Compare Source](ulikunitz/xz@v0.5.16...v0.5.17) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - Between 12:00 AM and 03:59 AM, only on Monday (`* 0-3 * * 1`) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 👻 **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xOTEuMiIsInVwZGF0ZWRJblZlciI6IjQzLjE5MS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> --------- Co-authored-by: silverwind <2021+silverwind@noreply.gitea.com> Reviewed-on: https://gitea.com/gitea/runner/pulls/1254 Reviewed-by: silverwind <2021+silverwind@noreply.gitea.com> Co-authored-by: Renovate Bot <renovate-bot@gitea.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 #113. A character class inside a brace alternation (e.g.
{[}],a}or{[a,b]x.md,real/path.txt}) was not skipped when the matcher scanned for the next alternative or the matching closing brace, so commas and braces contained in the class were treated as alternation syntax. As a result,ValidatePatternblessed patterns thatMatchcould never match.Root cause
Two helper scanners didn't account for character classes:
indexNextAlt(utils.go) — found the comma splitting alternatives; a comma inside a class was misread as a separator.indexMatchedClosingAlt(match.go) — found the matching}; a}inside a class was misread as the closing brace.The validator (
doValidatePattern) already skips character classes correctly, which is why it approved these patterns while the matcher rejected them.Change
Skip
[...]character classes (including escaped bytes inside them) in both scanners, mirroring what the validator already does. This applies only when the pattern uses/as the separator; on systems where\is the separator, escaping is disabled and classes are skipped at face value.Tests
Added regression rows to
matchTestscovering both a comma and a closing-brace inside a character class within a brace alternation:{[a,b]x.md,real/path.txt}matchesax.md,bx.md,real/path.txt, but notcx.md{[}],a}matches},a, but notbVerified the rows fail on unpatched upstream (
TestMatchreported "syntax error in pattern" for these patterns) and pass with this change. Full suite:go test -count=1 ./...→ ok,go vetclean.Notes
Assistance disclosure: this change was developed with the help of an AI coding assistant (Claude Code by Anthropic).