|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24560 parse_url() missing "host" with file:// scheme
Submitted: 2003-07-09 06:31 UTC Modified: 2003-07-21 08:37 UTC
From: tim at digicol dot de Assigned: iliaa (profile)
Status: Closed Package: URL related
PHP Version: 4.3.3RC2-dev OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: tim at digicol dot de
New email:
PHP Version: OS:


 [2003-07-09 06:31 UTC] tim at digicol dot de
parse_url() now prepends the "path" part with the hostname for "file://" scheme URLs.

In PHP 4.3.0 and all previous versions we've used (including PHP 3), "file://localhost/path" produced "[path] => /path".

In 4.3.2, this has become "[path] => localhost/path", which obviously breaks any code trying to access this on the filesystem.

Please fix this in PHP 4.3.3 to keep backwards compatibility.

(Maybe this has been broken while fixing ?)

Use "file:/path" URLs (not tested under PHP 3).
"file:///path" doesn't work in older PHP versions (PHP 4.0.6 says "PHP Warning: unable to parse url").

Reproduce code:

Expected result:
    [scheme] => file
    [host] => localhost
    [path] => /dir/subdir/file.txt

Actual result:
    [scheme] => file
    [path] => localhost/dir/subdir/file.txt


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-09 17:11 UTC]
Ilia, you have been touching this a lot..

file://localhost/some/path == file:///some/path

ie. They should both produce same path: /some/path ??
(and the // one should have host set too)

(at least that's how I interpret this:

 [2003-07-21 08:37 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

 [2021-01-28 05:02 UTC] dimat9569 at gmail dot com
Thanks for the information, keep sharing this type of info, Thanks for the info i will try to figure it out for more
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun May 28 16:03:40 2023 UTC