From: Anatol Belski Date: Tue, 24 Jan 2017 16:56:00 +0000 (+0100) Subject: dirname() should not normalize paths X-Git-Tag: php-7.1.2RC1~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ec78507bd46a05f77dbde3fa4091ab4c91e61cad;p=php dirname() should not normalize paths This is the BC piece with the case where dirname() is used with an URL. --- 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-- + +--FILE-- += 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; }