Bug #43721 [Com]: parse_url does not handle "protocol relative" URLs
Edit report at https://bugs.php.net/bug.php?id=43721&edit=1
ID: 43721
Comment by: bluemoehre at gmx dot de
Reported by: phpbugs at thequod dot de
Summary: parse_url does not handle "protocol relative" URLs
Status: Not a bug
Type: Bug
Package: URL related
Operating System: Ubuntu Linux
PHP Version: 5.2.5
Block user comment: N
Private report: N
New Comment:
Today i had to build a workaround for that. This behaviour is unexpected and should be changed.
Previous Comments:
------------------------------------------------------------------------
[2013-09-22 17:30:48] yastrakhan at wikimedia dot org
I also think this is a very unintuitive behavior - protocol-relative URLs are very common, while the
file:// has very limited and archaic use. parse_url() should behave very similar to modern browsers.
------------------------------------------------------------------------
[2013-01-24 09:13:31] victor dot sollerhed at gmail dot com
I think this actually is a bug. Could this please be re-opened?
"A relative URL without a scheme (http: or https:) is valid, per RFC
3986:
"Uniform Resource Identifier (URI): Generic Syntax", Section 4.2. If a client
chokes on it, then it's the client's fault because they're not
complying with the URI syntax specified in the RFC."
Please see:
http://stackoverflow.com/questions/550038/is-it-valid-to-replace-http-with-in-a-
script-src-http
http://stackoverflow.com/questions/3583103/network-path-reference-uri-scheme-
relative-urls/
------------------------------------------------------------------------
[2007-12-31 21:27:22] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
That's expected, because unless a protocol is specified, it assumes
file://
------------------------------------------------------------------------
[2007-12-31 18:10:32] phpbugs at thequod dot de
Description:
------------
parse_url does not parse "protocol relative" URLs correctly.
"protocol relative" URLs start with to slashes, leaving the "proto:"
part out.
parse_url should parse them like a "http://" url, but leave
the "protocol" key unset, as far as I can see.
See RFC3986.
Reproduce code:
---------------
$ php -r '$p = parse_url("//example.com/bar"); var_dump($p);'
Expected result:
----------------
array(2) {
["host"]=>
string(11) "example.com"
["path"]=>
string(17) "/bar"
}
Actual result:
--------------
array(1) {
["path"]=>
string(17) "//example.com/bar"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=43721&edit=1
Thread (5 messages)