xref: /PHP-7.4/ext/standard/tests/dir/bug72625.phpt (revision ec78507b)
1--TEST--
2Bug #72625 realpath() fails on very long argument.
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) != 'WIN') {
6  die("skip Valid only on Windows");
7}
8?>
9--FILE--
10<?php
11
12$base = sys_get_temp_dir() . "/" . md5(uniqid());
13while (strlen($base) < 260) {
14	$base = "$base/" . md5(uniqid());
15}
16
17$f0 = "$base/_test/documents/projects/myproject/vendor/name/library/classpath";
18$f1 = "$f0/../../../../../../../../_test/documents/projects/myproject/vendor/name/library/../../../../../../../_test/documents/projects/myproject/vendor/name/library/classpath";
19
20
21mkdir($f0, 0777, true);
22
23
24var_dump(
25	$f0,
26	file_exists($f0),
27	realpath($f0),
28	dirname($f0),
29
30	$f1,
31	file_exists($f1),
32	realpath($f1),
33	dirname($f1)
34);
35
36$tmp = $f0;
37while ($tmp > $base) {
38	rmdir($tmp);
39	$tmp = dirname($tmp);
40}
41
42?>
43===DONE===
44--EXPECTF--
45string(%d) "%s/_test/documents/projects/myproject/vendor/name/library/classpath"
46bool(true)
47string(%d) "%s\_test\documents\projects\myproject\vendor\name\library\classpath"
48string(%d) "%s/_test/documents/projects/myproject/vendor/name/library"
49string(%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"
50bool(true)
51string(%d) "%s\_test\documents\projects\myproject\vendor\name\library\classpath"
52string(%d) "%s/_test/documents/projects/myproject/vendor/name/library"
53===DONE===
54