php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62871 mkdir(): wrong behaviour parsing schema:// in parameters
Submitted: 2012-08-20 10:42 UTC Modified: 2021-08-23 17:00 UTC
Votes:9
Avg. Score:4.3 ± 0.8
Reproduced:8 of 8 (100.0%)
Same Version:4 (50.0%)
Same OS:2 (25.0%)
From: php dot net at thermoman dot de Assigned: cmb (profile)
Status: Closed Package: Directory function related
PHP Version: 5.4.6 OS: Linux 2.6.37.6
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php dot net at thermoman dot de
New email:
PHP Version: OS:

 

 [2012-08-20 10:42 UTC] php dot net at thermoman dot de
Description:
------------
mkdir does parse :// in argument as schema/protocol and truncates the string resulting in wrong directory being created.

Possibly more functions affected (fopen, ...).

mkdir("/var/tmp/http://foobar", 0700, true);
mkdir("/var/tmp/abcd://barbaz", 0700, true);

Creates wrong directories.

Test script:
---------------
% find foobar /var/tmp/http:

find: `foobar': No such file or directory
find: `/var/tmp/http:': No such file or directory

% ~/php546/bin/php -r 'var_dump(mkdir("/var/tmp/http://foobar", 0700, true));'
bool(true)

% find foobar /var/tmp/http:

foobar
find: `/var/tmp/http:': No such file or directory


==> PHP created directory 'foobar' in current working directory

Expected result:
----------------
directory "/var/tmp/http:" is created
directory "/var/tmp/http:/foobar" is created

like gnu mkdir:

% mkdir -p "/var/tmp/http://foobar"

% find /var/tmp/http:

/var/tmp/http:

/var/tmp/http:/foobar


Actual result:
--------------
directory "foobar" is created in current working directory

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-08-23 17:00 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-08-23 17:00 UTC] cmb@php.net
This has apparently been fixed in the meantime (tested with
PHP-7.4).
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 10:01:33 2025 UTC