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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
34 - 7 = ?
Subscribe to this entry?

 
 [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: Sat Apr 20 03:01:28 2024 UTC