diff options
author | Anatol Belski <ab@php.net> | 2017-01-24 17:56:00 +0100 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2017-01-24 17:56:00 +0100 |
commit | ec78507bd46a05f77dbde3fa4091ab4c91e61cad (patch) | |
tree | d3f8efafea03e63fb92832c93fb21dac41781733 | |
parent | 403f3524820a6bfef5873e88f258bf5aafe33ed7 (diff) | |
download | php-git-ec78507bd46a05f77dbde3fa4091ab4c91e61cad.tar.gz |
dirname() should not normalize paths
This is the BC piece with the case where dirname() is used with an URL.
-rw-r--r-- | ext/standard/tests/dir/bug72625.phpt | 4 | ||||
-rw-r--r-- | ext/standard/tests/file/dirname_no_path_normalization-win32.phpt | 27 | ||||
-rw-r--r-- | win32/ioutil.c | 3 |
3 files changed, 31 insertions, 3 deletions
diff --git a/ext/standard/tests/dir/bug72625.phpt b/ext/standard/tests/dir/bug72625.phpt index c89f955c3d..b64010fcd4 100644 --- a/ext/standard/tests/dir/bug72625.phpt +++ b/ext/standard/tests/dir/bug72625.phpt @@ -45,9 +45,9 @@ while ($tmp > $base) { string(%d) "%s/_test/documents/projects/myproject/vendor/name/library/classpath" bool(true) string(%d) "%s\_test\documents\projects\myproject\vendor\name\library\classpath" -string(%d) "%s\_test\documents\projects\myproject\vendor\name\library" +string(%d) "%s/_test/documents/projects/myproject/vendor/name/library" string(%d) "%s/_test/documents/projects/myproject/vendor/name/library/classpath/../../../../../../../../_test/documents/projects/myproject/vendor/name/library/../../../../../../../_test/documents/projects/myproject/vendor/name/library/classpath" bool(true) string(%d) "%s\_test\documents\projects\myproject\vendor\name\library\classpath" -string(%d) "%s\_test\documents\projects\myproject\vendor\name\library" +string(%d) "%s/_test/documents/projects/myproject/vendor/name/library" ===DONE=== diff --git a/ext/standard/tests/file/dirname_no_path_normalization-win32.phpt b/ext/standard/tests/file/dirname_no_path_normalization-win32.phpt new file mode 100644 index 0000000000..283834e8ce --- /dev/null +++ b/ext/standard/tests/file/dirname_no_path_normalization-win32.phpt @@ -0,0 +1,27 @@ +--TEST-- +Test dirname() function : regression with path normalization +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) != "WIN") + die("skip Only valid for Windows"); +?> +--FILE-- +<?php + +$s = '/php_sanity/sanity.php?'; +while (dirname($s) == "/php_sanity" && strlen($s) < 10000) { + $s .= str_repeat('X', 250); +} + +if (strlen($s) >= 10000) { + echo "OK\n"; +} else { + print "ERROR: " . PHP_EOL; + var_dump(dirname($s)); + var_dump(strlen($s)); +} +?> +===DONE=== +--EXPECT-- +OK +===DONE=== diff --git a/win32/ioutil.c b/win32/ioutil.c index de7aa77994..6fb89c46ed 100644 --- a/win32/ioutil.c +++ b/win32/ioutil.c @@ -445,7 +445,8 @@ PW32IO size_t php_win32_ioutil_dirname(char *path, size_t len) start = path; - startw = pathw = php_win32_ioutil_conv_any_to_w(path, len, &pathw_len); + /* Don't really care about the path normalization, pure parsing here. */ + startw = pathw = php_win32_cp_conv_any_to_w(path, len, &pathw_len); if (!pathw) { return 0; } |