php.net |  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
 [2020-04-26 10:22 UTC] 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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-04-26 21:03 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC