-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Open
Description
Description
Create a file c:\test[x]\test.php
(yes, it is important that it is in the directory named test[x]
):
<?php
var_dump(glob('*'));
Resulted in this output:
array(0) {
}
But I expected this output instead:
array(1) {
[0]=>
string(8) "test.php"
}
The problem is that glob performs the expansion of [...]
characters in the mask. The mask does not contain these characters, but since it is not absolute, the current directory is added to it:
Line 445 in a651ae8
snprintf(work_pattern, MAXPATHLEN, "%s%c%s", cwd, DEFAULT_SLASH, pattern); |
And it contains these characters, so an unwanted expansion occurs. It is therefore necessary to escape these characters. At least the character [
must escaped, ie. replaced with [[]
sequence.
PHP Version
PHP 8.3
Operating System
Windows