php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44071 realpath does not handle drive letters correctly
Submitted: 2008-02-07 16:26 UTC Modified: 2008-07-20 16:15 UTC
From: csaba at alum dot mit dot edu Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.6 OS: Windows
Private report: No CVE-ID: None
 [2008-02-07 16:26 UTC] csaba at alum dot mit dot edu
Description:
------------
realpath does not handle a drive letters correctly, when the
drive letter is not followed by a backslash:

1)  When books is a subdirectory of the current working directory on the c: drive (getcwd) realpath("c:books") returns false


2)  realpath("c:.") and realpath("c:..") both return the three character string: C:\

Expected result:
----------------
1.  books\ should be suffixed onto the current working directory of the c: drive

2.  The current working directory of the c: drive (and one level higher for the case of ..) should be returned, instead of the root.

Csaba Gabor from Vienna


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-08 02:08 UTC] csaba at alum dot mit dot edu
is_file and is_dir seem to be similarly affected.
For example realpath("c:frump") will return false if
c:\frump does not exist (note the extra backslash),
whereas it should be checking for frump hanging off
the current directory on the c: drive
 [2008-02-18 12:20 UTC] csaba at alum dot mit dot edu
It's still a problem.  On my Win XP Pro, with
PHP 5.2.6-dev (cli) (built: Feb 13 2008 12:05:17)

php -r "var_dump(array(getcwd(),realpath('c:')));"

produced:

array(2) {
  [0]=>
  string(18) "C:\Winapps\PHP.net"
  [1]=>
  string(3) "C:\"
}

The second string is wrong - it should
have been the same as the first.
 [2008-07-20 16:15 UTC] pajoye@php.net
realpath expects a path, a drive letter is not a valid path.

By the way, some functions may be added to deal with the drives on windows like chdrive.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 08 20:01:30 2024 UTC