php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #66274 Support protocol-relative URLs in parse_url
Submitted: 2013-12-12 12:52 UTC Modified: 2015-01-27 00:20 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: dmorilha at gmail dot com Assigned: requinix (profile)
Status: Closed Package: URL related
PHP Version: Irrelevant OS: macosx
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: dmorilha at gmail dot com
New email:
PHP Version: OS:

 

 [2013-12-12 12:52 UTC] dmorilha at gmail dot com
Description:
------------
parse_url gets lost when providing an url with no scheme in front, this goes totally against the RFC which allows urls with no scheme

Test script:
---------------
php > echo var_dump(parse_url("//search.yahoo.com/search?p=car"));

array(2) {
  ["path"]=>
  string(25) "//search.yahoo.com/search"
  ["query"]=>
  string(5) "p=car"
}

php > echo var_dump(parse_url("http://search.yahoo.com/search?p=car"));

array(4) {
  ["scheme"]=>
  string(4) "http"
  ["host"]=>
  string(16) "search.yahoo.com"
  ["path"]=>
  string(7) "/search"
  ["query"]=>
  string(5) "p=car"
}

Expected result:
----------------
php > echo var_dump(parse_url("//search.yahoo.com/search?p=car"));

array(2) {
  ["host"]=>
  string(16) "search.yahoo.com"
  ["path"]=>
  string(7) "/search"
  ["query"]=>
  string(5) "p=car"
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-12 19:21 UTC] aharvey@php.net
-Summary: parse_url depends on scheme +Summary: Support protocol-relative URLs in parse_url -Type: Bug +Type: Feature/Change Request -Package: *General Issues +Package: URL related
 [2013-12-12 19:21 UTC] aharvey@php.net
At present, parse_url() is only documented as supporting absolute URLs, so this is effectively a feature request.
 [2015-01-26 22:14 UTC] me at evertpot dot com
Currently this is documented as:

> Partial URLs are also accepted

So perhaps this is now a bug again?
 [2015-01-27 00:20 UTC] requinix@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: requinix
 [2015-01-27 00:20 UTC] requinix@php.net
Fixed as of 5.4.7. http://3v4l.org/d8hSL

("PHP Version" isn't irrelevant, folks!)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 15:01:36 2025 UTC