com php-src: dirname() should not normalize paths: ext/standard/tests/dir/bug72625.phpt ext/standard/tests/file/di
rname_no_path_normalization-win32.phpt win32/ ioutil.c

From: Date: Tue, 24 Jan 2017 16:56:00 +0000
Subject: com php-src: dirname() should not normalize paths: ext/standard/tests/dir/bug72625.phpt ext/standard/tests/file/di
rname_no_path_normalization-win32.phpt win32/ ioutil.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-96864@lists.php.net to get a copy of this message
Commit: ec78507bd46a05f77dbde3fa4091ab4c91e61cad Author: Anatol Belski <ab@php.net> Tue, 24 Jan 2017 17:56:00 +0100 Parents: 403f3524820a6bfef5873e88f258bf5aafe33ed7 Branches: PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ec78507bd46a05f77dbde3fa4091ab4c91e61cad Log: dirname() should not normalize paths This is the BC piece with the case where dirname() is used with an URL. Changed paths: M ext/standard/tests/dir/bug72625.phpt A ext/standard/tests/file/dirname_no_path_normalization-win32.phpt M win32/ioutil.c Diff: diff --git a/ext/standard/tests/dir/bug72625.phpt b/ext/standard/tests/dir/bug72625.phpt index c89f955..b64010f 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 0000000..283834e --- /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 de7aa77..6fb89c4 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; }

« previous php.cvs (#96864) next »