Bug #79522 [Opn->Nab]: parse_url failed with // in partial url PHP_URL_PATH
| From: | requinix@php.net | Date: | Sun, 26 Apr 2020 21:03:15 +0000 |
| Subject: | Bug #79522 [Opn->Nab]: parse_url failed with // in partial url PHP_URL_PATH | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-226780@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79522&edit=1
ID: 79522
Updated by: requinix@php.net
Reported by: rei-ayanami at gmx dot net
Summary: parse_url failed with // in partial url PHP_URL_PATH
-Status: Open
+Status: Not a bug
Type: Bug
Package: *URL Functions
Operating System: centOS 7.7
PHP Version: 7.4.5
Block user comment: N
Private report: N
New Comment:
https://3v4l.org/RdXsK The URL is being parsed correctly.
https://www.google.com/search?q=urls+starting+with+a+double+slash
Previous Comments:
------------------------------------------------------------------------
[2020-04-26 10:22:06] rei-ayanami at gmx dot net
Description:
------------
doc said https://www.php.net/manual/en/function.parse-url
> Partial URLs are also accepted, parse_url() tries its best to parse them correctly.
Like this "https://bugs.php.net///////report.php"
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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79522&edit=1