dirname() should not normalize paths

This is the BC piece with the case where dirname() is used with an URL.
This commit is contained in:
Anatol Belski 2017-01-24 17:56:00 +01:00
parent 403f352482
commit ec78507bd4
3 changed files with 31 additions and 3 deletions

View file

@ -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===

View file

@ -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===

View file

@ -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;
}