|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79522 parse_url failed with // in partial url PHP_URL_PATH
Submitted: 2020-04-26 10:22 UTC Modified: 2020-04-26 21:03 UTC
From: rei-ayanami at gmx dot net Assigned:
Status: Not a bug Package: *URL Functions
PHP Version: 7.4.5 OS: centOS 7.7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: rei-ayanami at gmx dot net
New email:
PHP Version: OS:


 [2020-04-26 10:22 UTC] rei-ayanami at gmx dot net
doc said
> Partial URLs are also accepted, parse_url() tries its best to parse them correctly.

Like this "" is a valid URL. So I add "//" instead of "/" for relative url and function return wrong result.

This happen with wrong user input in browser address bar and using  parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);

Test script:
// Working for absolute url
$url = 'http://username:password@hostname:9090//path?arg=value#anchor';
var_dump(parse_url($url, PHP_URL_PATH));
result: string(6) "//path"

Add: But it should return "/path" instead of "//path"?

// Failed for relative url
$url = '//path?arg=value#anchor';
var_dump(parse_url($url, PHP_URL_PATH));
result: NULL

Should be "//path" or better "/path" but not NULL.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-04-26 21:03 UTC]
-Status: Open +Status: Not a bug
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Mar 03 07:01:28 2024 UTC