php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68917 parse_url fails on some partial urls
Submitted: 2015-01-26 22:16 UTC Modified: 2015-03-04 08:16 UTC
From: me at evertpot dot com Assigned: demon (profile)
Status: Closed Package: *URL Functions
PHP Version: 5.6.5 OS: any
Private report: No CVE-ID: None
 [2015-01-26 22:16 UTC] me at evertpot dot com
Description:
------------
parse_url will fail for urls that don't have a scheme, but do have a port

Test script:
---------------
<?php

print_r(parse_url('//example.org:81/hi?a=b#c=d'));
print_r(parse_url('//example.org/hi?a=b#c=d'));

Expected result:
----------------
Array
(
    [host] => example.org
    [port] => 81
    [path] => /hi
    [query] => a=b
    [fragment] => c=d
)
Array
(
    [host] => example.org
    [path] => /hi
    [query] => a=b
    [fragment] => c=d
)

Actual result:
--------------
Array
(
    [host] => example.org
    [path] => /hi
    [query] => a=b
    [fragment] => c=d
)

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-01-27 00:16 UTC] requinix@php.net
-Status: Open +Status: Verified
 [2015-01-27 00:16 UTC] requinix@php.net
http://3v4l.org/MpY8k

I can't quite wrap my head around what ext/standard/url.c's php_url_parse_ex is doing without a debugger but it seems the combination of a colon + numbers and leading slash(es) confuses the code.

It also seems like the same problem as in bug #66813 except this time the (unencoded) colon is in the right location.
 [2015-01-27 00:43 UTC] me at evertpot dot com
Yea, I think it can really use a deep look into RFC3986 and a fresh start :) It looks like it had a number of edge-cases fixed in the past.
 [2015-03-04 08:16 UTC] demon@php.net
-Assigned To: +Assigned To: demon
 [2015-03-06 13:04 UTC] datibbaw@php.net
Automatic comment on behalf of datibbaw
Revision: http://git.php.net/?p=php-src.git;a=commit;h=d7fb52ea20aba5c9ef53dfa57af3b62717c9e9e5
Log: Fixed bug #68917 (parse_url fails on some partial urls)
 [2015-03-06 13:04 UTC] datibbaw@php.net
-Status: Verified +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC