php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #67875 parse_url behavior request
Submitted: 2014-08-20 17:58 UTC Modified: 2016-06-25 02:15 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: christopher dot geisel at gmail dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5.4.31 OS: CentOS 6.5
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2014-08-20 17:58 UTC] christopher dot geisel at gmail dot com
Description:
------------
parse_url feature request: parse on "/" for path

The behavior where parse_url sets "path" in the absence of a scheme/port is documented, but not intuitive.

Proposal: parse on "/" for the path. In the absence of scheme/port, set host with whatever precedes the path.

Test script:
---------------
https://gist.github.com/cgeisel/d85f1175d570fb20534e

Expected result:
----------------
See comments in gist


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-08-20 18:35 UTC] requinix@php.net
It may not be intuitive but it is the correct behavior: clicking a
  <a href="www.example.com">Go to http://www.example.com</a>
will not take you to the example domain.

Custom TLDs make this even worse. "example.com", sure it's a .com so it's probably a domain, but what about "example.foo" or "example.xyz"? I've seen those used as file extensions to obscure the underlying language. (Poorly.) There's even "example.cab" which IS an actual file extension - not to mention ".com" itself.

Besides that is the argument that it should parse according to the rules for a URL (RFC 3986).

If you want to force a domain name, all you have to do is prefix a "//".
 [2016-06-25 02:11 UTC] webmaster at tubo-world dot de
This issue should be closed.

The URI reference "example.com/foo" is a relative path reference.
So example.com is not the host in the above URI as you expect wrongly.
See RFC 3986.

The correct URI reference would be "//example.com/foo" for what you are trying to express.
 [2016-06-25 02:15 UTC] requinix@php.net
-Status: Open +Status: Wont fix
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC