Bug #79522 [NEW]: parse_url failed with // in partial url PHP_URL_PATH

From: Date: Sun, 26 Apr 2020 10:22:07 +0000
Subject: Bug #79522 [NEW]: parse_url failed with // in partial url PHP_URL_PATH
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226774@lists.php.net to get a copy of this message
From:             rei-ayanami at gmx dot net
Operating system: centOS 7.7
PHP version:      7.4.5
Package:          *URL Functions
Bug Type:         Bug
Bug description:parse_url failed with // in partial url PHP_URL_PATH

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 bug report at https://bugs.php.net/bug.php?id=79522&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79522&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79522&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79522&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79522&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79522&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79522&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79522&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79522&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79522&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79522&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79522&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79522&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79522&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79522&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79522&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79522&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79522&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#226774) next »