From: Pierrick Charron Date: Thu, 17 Mar 2011 18:02:58 +0000 (+0000) Subject: Fixed bug #54180 (parse_url() incorrectly parses path when ? in fragment) X-Git-Tag: php-5.3.7RC1~233 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5a53a74304941a1929484de42d3c04296d124510;p=php Fixed bug #54180 (parse_url() incorrectly parses path when ? in fragment) --- diff --git a/NEWS b/NEWS index 7d3789e5a9..84e8f4e08f 100644 --- a/NEWS +++ b/NEWS @@ -5,7 +5,11 @@ PHP NEWS - Zend Engine: . Fixed bug #54262 (Crash when assigning value to a dimension in a non-array). (Dmitry) - + +- Core: + . Fixed bug #54180 (parse_url() incorrectly parses path when ? in fragment). + (tomas dot brastavicius at quantum dot lt, Pierrick) + - DBA extension: . Fixed bug #54242 (dba_insert returns true if key already exists). (Felipe) diff --git a/ext/standard/tests/url/bug54180.phpt b/ext/standard/tests/url/bug54180.phpt new file mode 100644 index 0000000000..2e64e27d07 --- /dev/null +++ b/ext/standard/tests/url/bug54180.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #54180 (parse_url() incorrectly parses path when ? in fragment) +--FILE-- + +--EXPECTF-- +array(5) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "example.com" + ["path"]=> + string(17) "/path/script.html" + ["query"]=> + string(3) "t=1" + ["fragment"]=> + string(13) "fragment?data" +} +array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "example.com" + ["path"]=> + string(17) "/path/script.html" + ["fragment"]=> + string(13) "fragment?data" +} diff --git a/ext/standard/url.c b/ext/standard/url.c index e4f71b1460..0f4b836e62 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -316,6 +316,10 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length) pp = strchr(s, '#'); if (pp && pp < p) { + if (pp - s) { + ret->path = estrndup(s, (pp-s)); + php_replace_controlchars_ex(ret->path, (pp - s)); + } p = pp; goto label_parse; }