Repository navigation
fix(os/gfile): keep MatchGlob globstar matching separator-aware on windows - #4961
Merged
Merged
Conversation
…ndows The globstar path of MatchGlob normalizes both pattern and name to "/" separators and then calls filepath.Match. On Windows filepath.Match only treats "\" as a separator, so "*" matched across "/" there and, for example, "a**b" matched "a/b". Use path.Match on the normalized paths. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Malformed glob patterns now return path.ErrBadPattern instead of filepath.ErrBadPattern across three matching paths, breaking existing errors.Is checks and requiring error translation plus identity tests.
1 open issue
What changed in this PR
This PR fixes Windows separator handling in GoFrame’s gfile.MatchGlob, preventing ordinary * wildcards from matching across normalized path separators in globstar patterns.
Changes:
- Uses
path.Matchat three globstar matching sites where paths are already normalized to/. - Adds two Windows-path regression cases covering wildcard separator boundaries.
| File | Description |
|---|---|
os/gfile/gfile_z_unit_match_test.go |
Adds regression tests ensuring wildcards do not cross Windows path separators. |
os/gfile/gfile_match.go |
Switches normalized globstar matching to path.Match and updates explanatory comments. |
Review effort: Balanced
lingcoder
force-pushed
the
fix/gfile-matchglob-windows
branch
from
November 6, 2026 01:36
91456ac to
9b4d8ef
Compare
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.

Test_MatchGlob_InvalidGlobstarfails on Windows (CI only runs on Linux, so it doesn't show up there).The globstar branch of
MatchGlobconverts both the pattern and the name to/separators and then callsfilepath.Match. On Windowsfilepath.Matchonly treats\as a separator, so after the conversion*also matches/, e.g.MatchGlob("a**b", "a/b")returns true.This uses
path.Matchat the three globstar call sites, since the strings there are already/-separated. On Unix-like systems nothing changes, becausepath.Matchandfilepath.Matchbehave the same there. I also added two Windows-path cases toTest_MatchGlob_WindowsPath; both tests fail on master on Windows and pass with this change.