[php-src] master: Merge branch 'PHP-8.6'

From: Date: Tue, 20 Oct 2026 17:38:57 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142506@lists.php.net to get a copy of this message
Author: Weilin Du (LamentXU123) Date: 2026-10-21T01:36:26+08:00 Commit: https://github.com/php/php-src/commit/b9ea38ef639f5b9bbb67d27834be9c52b922520b Raw diff: https://github.com/php/php-src/commit/b9ea38ef639f5b9bbb67d27834be9c52b922520b.diff Merge branch 'PHP-8.6' * PHP-8.6: Merge branch 'PHP-8.5' into PHP-8.6 Changed paths: A ext/standard/tests/file/glob_bracket_negation.phpt M main/php_glob.c Diff: diff --git a/ext/standard/tests/file/glob_bracket_negation.phpt b/ext/standard/tests/file/glob_bracket_negation.phpt new file mode 100644 index 000000000000..3f5ef513789e --- /dev/null +++ b/ext/standard/tests/file/glob_bracket_negation.phpt @@ -0,0 +1,30 @@ +--TEST-- +glob() negates a bracket expression that starts with "!" or "^" +--FILE-- +<?php +$dir = __DIR__ . '/glob_bracket_negation'; +@mkdir($dir); +foreach (['a', 'b', 'c', '^', '!'] as $name) { + touch("$dir/$name"); +} + +foreach (['[!a]', '[^a]', '[!a-b]', '[^a-b]', '[!]a]', '[^]a]', '[a^]'] as $pattern) { + echo $pattern, ': ', implode(' ', array_map('basename', glob("$dir/$pattern"))), "\n"; +} +?> +--CLEAN-- +<?php +$dir = __DIR__ . '/glob_bracket_negation'; +foreach (['a', 'b', 'c', '^', '!'] as $name) { + @unlink("$dir/$name"); +} +@rmdir($dir); +?> +--EXPECT-- +[!a]: ! ^ b c +[^a]: ! ^ b c +[!a-b]: ! ^ c +[^a-b]: ! ^ c +[!]a]: ! ^ b c +[^]a]: ! ^ b c +[a^]: ^ a diff --git a/main/php_glob.c b/main/php_glob.c index 8edfb8326da4..af087c4530a6 100644 --- a/main/php_glob.c +++ b/main/php_glob.c @@ -107,6 +107,7 @@ #include "charclass.h" +#define CIRCUMFLEX '^' #define DOLLAR '$' #define DOT '.' #define EOS '\0' @@ -566,6 +567,12 @@ static int glob0(const Char *pattern, php_glob_t *pglob, struct glob_lim *limitp switch (c) { case LBRACKET: c = *qpatnext; + /* + * Not in OpenBSD's glob(), keep it when syncing: like fnmatch(), + * treat a leading '^' as '!'. + */ + if (c == CIRCUMFLEX) + c = NOT; if (c == NOT) ++qpatnext; if (*qpatnext == EOS ||

« previous php.cvs (#142506) next »