[php-src] PR #24422: Fix glob() not negating bracket expressions that start with "^"
| From: | nicolas-grekas | Date: | Mon, 19 Oct 2026 07:24:54 +0000 |
| Subject: | [php-src] PR #24422: Fix glob() not negating bracket expressions that start with "^" | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-39578@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/24422
Author: nicolas-grekas
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:
```php
// in a directory that contains the files a, b and ^
glob('[^a]'); // 8.4 on Linux: ['^', 'b'], 8.5: ['^',
'a']
```
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.