[php-src] Issue #13204: glob() fails if square bracket is in current directory

From: Date: Sat, 20 Jan 2024 18:32:32 +0000
Subject: [php-src] Issue #13204: glob() fails if square bracket is in current directory
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246301@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/13204 Author: dg ### Description Create a file c:\test[x]\test.php (yes, it is important that it is in the directory named test[x]): ```php <?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: https://github.com/php/php-src/blob/a651ae86aa2e4208f8471277ba69f26fb903e4e7/ext/standard/dir.c#L445 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

« previous php.bugs (#246301) next »