Edit report at http://bugs.php.net/bug.php?id=54369&edit=1
ID: 54369 Comment by: tokul at users dot sourceforge dot net Reported by: tomas dot brastavicius at quantum dot lt Summary: parse_url() incorrectly determines the start of query and fragment parts of URL Status: Open Type: Bug Package: URL related PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Check url encoding documentation first. http://en.wikipedia.org/wiki/Percent-encoding Then fix your $url value. You use reserved character for other purpose. Previous Comments: ------------------------------------------------------------------------ [2011-03-24 15:46:33] tomas dot brastavicius at quantum dot lt Description: ------------ Attached patch fixes the issue. Test script: --------------- $url = 'http://www.example.com#fra/gment'; echo $url . "\n"; var_dump(parse_url($url)); $url = 'http://www.example.com?p=1/param'; echo $url . "\n"; var_dump(parse_url($url)); // No host, should return false $url = 'http://#fra/gment'; echo $url . "\n"; var_dump(parse_url($url)); // No host, should return false $url = 'http://?p=1/param'; echo $url . "\n"; var_dump(parse_url($url)); Expected result: ---------------- http://www.example.com#fra/gment array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(15) "www.example.com" ["fragment"]=> string(9) "fra/gment" } http://www.example.com?p=1/param array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(15) "www.example.com" ["query"]=> string(9) "p=1/param" } http://#fra/gment bool(false) http://?p=1/param bool(false) Actual result: -------------- http://www.example.com#fra/gment array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(19) "www.example.com#fra" ["path"]=> string(6) "/gment" } http://www.example.com?p=1/param array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(19) "www.example.com?p=1" ["path"]=> string(6) "/param" } http://#fra/gment array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(4) "#fra" ["path"]=> string(6) "/gment" } http://?p=1/param array(3) { ["scheme"]=> string(4) "http" ["host"]=> string(4) "?p=1" ["path"]=> string(6) "/param" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54369&edit=1