Repository navigation
Fix glob() not negating bracket expressions that start with "^" - #24422
Open
nicolas-grekas wants to merge 2 commits into
Open
nicolas-grekas wants to merge 2 commits into
nicolas-grekas wants to merge 2 commits into
Conversation
nicolas-grekas
added a commit
to symfony/symfony
that referenced
this pull request
Oct 19, 2026
…or "^" in glob patterns (nicolas-grekas) This PR was merged into the 8.2 branch. Discussion ---------- [Finder] Negate bracket expressions that start with "!" or "^" in glob patterns | Q | A | ------------- | --- | Branch? | 8.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Follow-up to #67075. In glob patterns, `[!a]` and `[^a]` matched `!` or `^`, or `a`. They now match any character except `a`, as `fnmatch()` does. Like `?`, they don't match `/`, except when the regexp is built with `$strictWildcardSlash = false`, as AssetMapper does. This changes what `Finder::name()` and `notName()`, the `**` patterns of `GlobResource`, the `excluded_patterns` of AssetMapper and the `places` globs of Workflow match when a bracket starts with `!` or `^`. The native `glob()` path of `GlobResource` already negated them, so both paths now agree. Except for `[^`: since PHP 8.5, and on Windows, `glob()` reads `^` as a literal. php/php-src#24422 fixes that. Commits ------- 6f55435 [Finder] Negate bracket expressions that start with "!" or "^" in glob patterns
Member
|
I would make a note that it's a deviation from OpenBSD's glob implementation (less obvious than i.e. the ZendMM adaptation) in case we need to sync again in the future. |
Contributor
Author
|
Good point, comment updated. |
NattyNarwhal
approved these changes
Oct 19, 2026
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.
Since #18164, glob() uses the bundled implementation on all platforms. That implementation negates a bracket expression only when it starts with
!. Before, on Linux, the system glob() also negated[^a]. Since 8.5,^is a literal there:POSIX leaves
[^...]unspecified, but glibc and our own fnmatch() implementation treat it like[!...]. This PR does the same in glob(). On Windows,[^a]now negates too, like fnmatch() already does there.Found while working on symfony/symfony#67133.