Bug #72642 [NEW]: realpath() failing to expand path

From: Date: Thu, 21 Jul 2016 23:38:57 +0000
Subject: Bug #72642 [NEW]: realpath() failing to expand path
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202494@lists.php.net to get a copy of this message
From: anrdaemon at freemail dot ru Operating system: Windows PHP version: 7.1.0beta1 Package: Filesystem function related Bug Type: Bug Bug description:realpath() failing to expand path Description: ------------ realpath(), according to the documentation, is supposed to unwind every symlink and relative reference in the given string and produce an absolute and unambiguous path. Well… it doesn't perform its job quite as desired. Affected PHP versions: same behavior observed in 5.3.29, 5.6.23, 7.0.8 and 7.1.0b1. Test script: --------------- <?php $rootdir = substr($_SERVER['SystemRoot'], 0, 3); $tmpdir = getenv('TEMP'); shell_exec("mklink /J \"{$rootdir}home\" \"{$rootdir}Users\""); shell_exec("mklink /J \"{$tmpdir}\\test.dir\" \"{$rootdir}home\\Public\\Desktop\""); $file = "{$tmpdir}\\test.dir\\desktop.ini"; $rfile = realpath($file); printf("orig.file name: %s\n", $file); printf("realpath(name): %s\n", $rfile); printf("THE real name: %s\n", realpath($rfile)); if($rfile != realpath($rfile)) print "Fail as is.\n"; rmdir("{$rootdir}home"); rmdir("{$tmpdir}\\test.dir"); Expected result: ---------------- orig.file name: C:\Users\ANRDAE~1\AppData\Local\Temp\test.dir\desktop.ini realpath(name): C:\Users\Public\Desktop\desktop.ini THE real name: C:\Users\Public\Desktop\desktop.ini Actual result: -------------- orig.file name: C:\Users\ANRDAE~1\AppData\Local\Temp\test.dir\desktop.ini realpath(name): C:\home\Public\Desktop\desktop.ini THE real name: C:\Users\Public\Desktop\desktop.ini Fail as is. -- Edit bug report at https://bugs.php.net/bug.php?id=72642&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72642&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72642&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72642&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=72642&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=72642&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=72642&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=72642&r=needscript Try newer version: https://bugs.php.net/fix.php?id=72642&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=72642&r=support Expected behavior: https://bugs.php.net/fix.php?id=72642&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=72642&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=72642&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=72642&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72642&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=72642&r=dst IIS Stability: https://bugs.php.net/fix.php?id=72642&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=72642&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=72642&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=72642&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=72642&r=mysqlcfg

« previous php.bugs (#202494) next »