com php-src: fixed glob() edge case on windows, ref bug #47358: ext/standard/dir.c ext/standard/tests/file/glob_variation3 .phpt
| From: | Anatol Belski | Date: | Mon, 19 Aug 2013 12:21:16 +0000 |
| Subject: | com php-src: fixed glob() edge case on windows, ref bug #47358: ext/standard/dir.c ext/standard/tests/file/glob_variation3 .phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-72995@lists.php.net to get a copy of this message | ||
Commit: f4df40108be641a4167f6f6c1c3989958dda438a
Author: Anatol Belski <ab@php.net> Mon, 19 Aug 2013 14:21:16 +0200
Parents: f61b648da4df521b0aaed1c588ae3ac3ab2e540b
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f4df40108be641a4167f6f6c1c3989958dda438a
Log:
fixed glob() edge case on windows, ref bug #47358
Bugs:
https://bugs.php.net/47358
Changed paths:
M ext/standard/dir.c
M ext/standard/tests/file/glob_variation3.phpt
Diff:
diff --git a/ext/standard/dir.c b/ext/standard/dir.c
index 55326db..ca7e576 100644
--- a/ext/standard/dir.c
+++ b/ext/standard/dir.c
@@ -491,11 +491,18 @@ PHP_FUNCTION(glob)
/* now catch the FreeBSD style of "no matches" */
if (!globbuf.gl_pathc || !globbuf.gl_pathv) {
no_results:
+#ifndef PHP_WIN32
+ /* Paths containing '*', '?' and some other chars are
+ illegal on Windows but legit on other platforms. For
+ this reason the direct basedir check against the glob
+ query is senseless on windows. For instance while *.txt
+ is a pretty valid filename on EXT3, it's invalid on NTFS. */
if (PG(open_basedir) && *PG(open_basedir)) {
if (php_check_open_basedir_ex(pattern, 0 TSRMLS_CC)) {
RETURN_FALSE;
}
}
+#endif
array_init(return_value);
return;
}
diff --git a/ext/standard/tests/file/glob_variation3.phpt
b/ext/standard/tests/file/glob_variation3.phpt
index 4f504e6..9c57ada 100644
--- a/ext/standard/tests/file/glob_variation3.phpt
+++ b/ext/standard/tests/file/glob_variation3.phpt
@@ -6,9 +6,27 @@ $path = dirname(__FILE__);
ini_set('open_basedir', NULL);
var_dump(glob("$path/*.none"));
+var_dump(glob("$path/?.none"));
+var_dump(glob("$path/*{hello,world}.none"));
+var_dump(glob("$path/*/nothere"));
+var_dump(glob("$path/[aoeu]*.none"));
+var_dump(glob("$path/directly_not_exists"));
ini_set('open_basedir', $path);
var_dump(glob("$path/*.none"));
+var_dump(glob("$path/?.none"));
+var_dump(glob("$path/*{hello,world}.none"));
+var_dump(glob("$path/*/nothere"));
+var_dump(glob("$path/[aoeu]*.none"));
+var_dump(glob("$path/directly_not_exists"));
+
+ini_set('open_basedir', '/tmp');
+var_dump(glob("$path/*.none"));
+var_dump(glob("$path/?.none"));
+var_dump(glob("$path/*{hello,world}.none"));
+var_dump(glob("$path/*/nothere"));
+var_dump(glob("$path/[aoeu]*.none"));
+var_dump(glob("$path/directly_not_exists"));
?>
==DONE==
@@ -17,4 +35,36 @@ array(0) {
}
array(0) {
}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
+array(0) {
+}
==DONE==