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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rei-ayanami at gmx dot net
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Apr 18 23:01:27 2024 UTC