php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72367 Relative Drive:path incorrectly assumed to be Drive:\path
Submitted: 2016-06-09 09:38 UTC Modified: 2016-06-10 12:09 UTC
Votes:2
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: RQuadling at GMail dot com Assigned:
Status: Open Package: *Directory/Filesystem functions
PHP Version: 5.6.22 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: RQuadling at GMail dot com
New email:
PHP Version: OS:

 

 [2016-06-09 09:38 UTC] RQuadling at GMail dot com
Description:
------------
If you use a relative path to a file from Windows command line, PHP interprets the supplied location as a root.

The test script below requires a Windows setup with 2 drives (C and D). The script is a batch script that creates the test script and cleans up after itself.

Whilst this is similar in some aspects to previously reported bugs related to realpath(), the issue is that the constants __FILE__ and __DIR__ are correct, thus making them useless.

OOI, using the absolute path for the PHP script (C:\PHP56\PHP D:\ReaL\PaTH\BuG\TeSTBuG.php), produces the correct results.



Test script:
---------------
@ECHO OFF
REM Make directories for testing.
MD C:\Test\Real\PaTH\BuG
MD D:\ReaL\PaTH\BuG

REM Make test PHP script.
ECHO ^<?php > D:\ReaL\PaTH\BuG\TeSTBuG.php
ECHO var_export([PHP_VERSION, __FILE__, __DIR__, getcwd(), realpath(__FILE__), realpath(__DIR__), realpath(getcwd()), $argv]);>> D:\ReaL\PaTH\BuG\TeSTBuG.php

REM Make sure drives are in their directories.
CD /D D:\ReaL\PaTH\BuG
CD /D C:\Test\Real\PaTH\BuG

REM Call PHP using relative paths.
C:\PHP56\PHP D:TeSTBuG.php

REM Clean-up
DEL D:\ReaL\PaTH\BuG\TeSTBuG.php
CD /D D:\
CD /D C:\
RD C:\Test\Real\PaTH\BuG
RD D:\ReaL\PaTH\BuG


Expected result:
----------------
array (
  0 => '5.6.20',
  1 => 'D:\\ReaL\\PaTH\\BuG\\TeSTBuG.php',
  2 => 'D:\\ReaL\\PaTH\\BuG',
  3 => 'C:\\Test\\Real\\PaTH\\BuG',
  4 => D:\\ReaL\\PaTH\\BuG\\TeSTBuG.php,
  5 => 'D:\\ReaL\\PaTH\\BuG',
  6 => 'C:\\Test\\Real\\PaTH\\BuG',
  7 =>
  array (
    0 => 'D:TeSTBuG.php',
  ),
)

Actual result:
--------------
array (
  0 => '5.6.20',
  1 => 'D:\\TeSTBuG.php',
  2 => 'D:\\',
  3 => 'C:\\Test\\Real\\PaTH\\BuG',
  4 => false,
  5 => 'D:\\',
  6 => 'C:\\Test\\Real\\PaTH\\BuG',
  7 =>
  array (
    0 => 'D:TeSTBuG.php',
  ),
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-10 12:05 UTC] RQuadling at GMail dot com
Typo in my initial report ...

Whilst this is similar in some aspects to previously reported bugs related to realpath(), the issue is that the constants __FILE__ and __DIR__ are INCORRECT, thus making them useless.
 [2016-06-10 12:09 UTC] rquadling@php.net
-Summary: Relative Drive:path incorrectly assumed to be Drive:/path +Summary: Relative Drive:path incorrectly assumed to be Drive:\path
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed May 27 12:01:27 2020 UTC