php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22423 parse_url() -> file:// not parsed correctly
Submitted: 2003-02-25 16:40 UTC Modified: 2003-02-25 17:38 UTC
From: sbriesen at gmx dot de Assigned:
Status: Closed Package: *URL Functions
PHP Version: 4.3.1 OS: SuSE 8.1
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: sbriesen at gmx dot de
New email:
PHP Version: OS:

 

 [2003-02-25 16:40 UTC] sbriesen at gmx dot de
$x=parse_url('file:///any/path/file.ext');

gives you:

Array
(
    [scheme] => file
    [host] => /any/path/file.ext
)

$x=parse_url('file://localhost/any/path/file.ext');

gives you:

Array
(
    [scheme] => file
    [host] => localhost
    [path] => /any/path/file.ext
)

the first one is definitively parsed wrong!!! in a file:// url, the 'host' is optional and is located between :// and the first slash.

scheme://[[user[:pass]@]host]/path

so 

$x=parse_url('file:///any/path/file.ext');

*should* give you:

Array
(
    [scheme] => file
    [path] => /any/path/file.ext
)

and nothing else!

btw: have you ever seen a 'host' with slashes? ;-)

btw^2: a 'join_url' (or similar) should be also available (as the counterpart to 'parse_url'). Yes, I know, I can write such function for myself in plain PHP. But there should be always the opposite counterpart available as a native PHP function!

btw^3: not all file-functions are capable to handle file:// urls correctly. I know, that is not your problem... ;-) I will try to find all that functions and create a seperate bugreport.


regards,
Stefan

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-02-25 17:38 UTC] iliaa@php.net
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 http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

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


 [2003-05-01 17:29 UTC] freesoftware at xs4all dot nl
Does this fix also handle file:// paths with driveletters correctely?

eg $x=parse_url('file://C:/any/path/file.ext');

I can imagine it breaks over the second :
Anyway, I've seen applications that sent this as a referrer in GET requests (Microsoft XML ActiveX control)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 13:01:29 2024 UTC