]> granicus.if.org Git - php/commitdiff
dirname() should not normalize paths
authorAnatol Belski <ab@php.net>
Tue, 24 Jan 2017 16:56:00 +0000 (17:56 +0100)
committerAnatol Belski <ab@php.net>
Tue, 24 Jan 2017 16:56:00 +0000 (17:56 +0100)
This is the BC piece with the case where dirname() is used with an URL.

ext/standard/tests/dir/bug72625.phpt
ext/standard/tests/file/dirname_no_path_normalization-win32.phpt [new file with mode: 0644]
win32/ioutil.c

index c89f955c3df13dd9f57d1501ebab75b67bb0ffd5..b64010fcd4f1ccae4fc7cf9cf99b50e660e43d1c 100644 (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===
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 (file)
index 0000000..283834e
--- /dev/null
@@ -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===
index de7aa7799430eb33f8ef5c05b406fecbb67e2d60..6fb89c46ed60480d06d0e6f40d16e7ffb21e7d98 100644 (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;
        }