From: Nikita Popov Date: Fri, 7 Oct 2016 23:04:22 +0000 (+0200) Subject: Fix bug #73192 X-Git-Tag: php-5.6.28RC1~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b061fa909de77085d3822a89ab901b934d0362c4;p=php Fix bug #73192 --- diff --git a/ext/standard/tests/url/bug73192.phpt b/ext/standard/tests/url/bug73192.phpt new file mode 100644 index 0000000000..6ecb47718d --- /dev/null +++ b/ext/standard/tests/url/bug73192.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #73192: parse_url return wrong hostname +--FILE-- + +--EXPECT-- +array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "example.com" + ["port"]=> + int(80) + ["fragment"]=> + string(12) "@google.com/" +} +array(4) { + ["scheme"]=> + string(4) "http" + ["host"]=> + string(11) "example.com" + ["port"]=> + int(80) + ["query"]=> + string(12) "@google.com/" +} diff --git a/ext/standard/tests/url/parse_url_basic_001.phpt b/ext/standard/tests/url/parse_url_basic_001.phpt index 0708691fe3..e468066a42 100644 --- a/ext/standard/tests/url/parse_url_basic_001.phpt +++ b/ext/standard/tests/url/parse_url_basic_001.phpt @@ -763,25 +763,9 @@ echo "Done"; int(6) } ---> http://?:/: array(3) { - ["scheme"]=> - string(4) "http" - ["host"]=> - string(1) "?" - ["path"]=> - string(1) "/" -} +--> http://?:/: bool(false) ---> http://@?:/: array(4) { - ["scheme"]=> - string(4) "http" - ["host"]=> - string(1) "?" - ["user"]=> - string(0) "" - ["path"]=> - string(1) "/" -} +--> http://@?:/: bool(false) --> file:///:: array(2) { ["scheme"]=> diff --git a/ext/standard/tests/url/parse_url_basic_002.phpt b/ext/standard/tests/url/parse_url_basic_002.phpt index c05d1f487a..f222ffccf3 100644 --- a/ext/standard/tests/url/parse_url_basic_002.phpt +++ b/ext/standard/tests/url/parse_url_basic_002.phpt @@ -98,8 +98,8 @@ echo "Done"; --> http://::? : string(4) "http" --> http://::# : string(4) "http" --> x://::6.5 : string(1) "x" ---> http://?:/ : string(4) "http" ---> http://@?:/ : string(4) "http" +--> http://?:/ : bool(false) +--> http://@?:/ : bool(false) --> file:///: : string(4) "file" --> file:///a:/ : string(4) "file" --> file:///ab:/ : string(4) "file" diff --git a/ext/standard/tests/url/parse_url_basic_003.phpt b/ext/standard/tests/url/parse_url_basic_003.phpt index 88eda504d5..70dc4bb90b 100644 --- a/ext/standard/tests/url/parse_url_basic_003.phpt +++ b/ext/standard/tests/url/parse_url_basic_003.phpt @@ -97,8 +97,8 @@ echo "Done"; --> http://::? : string(1) ":" --> http://::# : string(1) ":" --> x://::6.5 : string(1) ":" ---> http://?:/ : string(1) "?" ---> http://@?:/ : string(1) "?" +--> http://?:/ : bool(false) +--> http://@?:/ : bool(false) --> file:///: : NULL --> file:///a:/ : NULL --> file:///ab:/ : NULL diff --git a/ext/standard/tests/url/parse_url_basic_004.phpt b/ext/standard/tests/url/parse_url_basic_004.phpt index e3b9abd91c..7ddddaf716 100644 --- a/ext/standard/tests/url/parse_url_basic_004.phpt +++ b/ext/standard/tests/url/parse_url_basic_004.phpt @@ -97,8 +97,8 @@ echo "Done"; --> http://::? : NULL --> http://::# : NULL --> x://::6.5 : int(6) ---> http://?:/ : NULL ---> http://@?:/ : NULL +--> http://?:/ : bool(false) +--> http://@?:/ : bool(false) --> file:///: : NULL --> file:///a:/ : NULL --> file:///ab:/ : NULL diff --git a/ext/standard/tests/url/parse_url_basic_005.phpt b/ext/standard/tests/url/parse_url_basic_005.phpt index 5b2cb98f8b..b2ca06ff96 100644 --- a/ext/standard/tests/url/parse_url_basic_005.phpt +++ b/ext/standard/tests/url/parse_url_basic_005.phpt @@ -97,8 +97,8 @@ echo "Done"; --> http://::? : NULL --> http://::# : NULL --> x://::6.5 : NULL ---> http://?:/ : NULL ---> http://@?:/ : string(0) "" +--> http://?:/ : bool(false) +--> http://@?:/ : bool(false) --> file:///: : NULL --> file:///a:/ : NULL --> file:///ab:/ : NULL diff --git a/ext/standard/tests/url/parse_url_basic_006.phpt b/ext/standard/tests/url/parse_url_basic_006.phpt index 79af6b8b62..f0c251bb55 100644 --- a/ext/standard/tests/url/parse_url_basic_006.phpt +++ b/ext/standard/tests/url/parse_url_basic_006.phpt @@ -97,8 +97,8 @@ echo "Done"; --> http://::? : NULL --> http://::# : NULL --> x://::6.5 : NULL ---> http://?:/ : NULL ---> http://@?:/ : NULL +--> http://?:/ : bool(false) +--> http://@?:/ : bool(false) --> file:///: : NULL --> file:///a:/ : NULL --> file:///ab:/ : NULL diff --git a/ext/standard/tests/url/parse_url_basic_007.phpt b/ext/standard/tests/url/parse_url_basic_007.phpt index 8e04553983..1b362bb013 100644 --- a/ext/standard/tests/url/parse_url_basic_007.phpt +++ b/ext/standard/tests/url/parse_url_basic_007.phpt @@ -97,8 +97,8 @@ echo "Done"; --> http://::? : NULL --> http://::# : NULL --> x://::6.5 : NULL ---> http://?:/ : string(1) "/" ---> http://@?:/ : string(1) "/" +--> http://?:/ : bool(false) +--> http://@?:/ : bool(false) --> file:///: : string(2) "/:" --> file:///a:/ : string(3) "a:/" --> file:///ab:/ : string(5) "/ab:/" diff --git a/ext/standard/tests/url/parse_url_basic_008.phpt b/ext/standard/tests/url/parse_url_basic_008.phpt index 0c77221465..1271f3838c 100644 --- a/ext/standard/tests/url/parse_url_basic_008.phpt +++ b/ext/standard/tests/url/parse_url_basic_008.phpt @@ -97,8 +97,8 @@ echo "Done"; --> http://::? : NULL --> http://::# : NULL --> x://::6.5 : NULL ---> http://?:/ : NULL ---> http://@?:/ : NULL +--> http://?:/ : bool(false) +--> http://@?:/ : bool(false) --> file:///: : NULL --> file:///a:/ : NULL --> file:///ab:/ : NULL diff --git a/ext/standard/tests/url/parse_url_basic_009.phpt b/ext/standard/tests/url/parse_url_basic_009.phpt index 487b271149..72f172a55b 100644 --- a/ext/standard/tests/url/parse_url_basic_009.phpt +++ b/ext/standard/tests/url/parse_url_basic_009.phpt @@ -97,8 +97,8 @@ echo "Done"; --> http://::? : NULL --> http://::# : NULL --> x://::6.5 : NULL ---> http://?:/ : NULL ---> http://@?:/ : NULL +--> http://?:/ : bool(false) +--> http://@?:/ : bool(false) --> file:///: : NULL --> file:///a:/ : NULL --> file:///ab:/ : NULL diff --git a/ext/standard/url.c b/ext/standard/url.c index dd861a570d..962718459a 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -217,28 +217,7 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length) goto nohost; } - e = ue; - - if (!(p = memchr(s, '/', (ue - s)))) { - char *query, *fragment; - - query = memchr(s, '?', (ue - s)); - fragment = memchr(s, '#', (ue - s)); - - if (query && fragment) { - if (query > fragment) { - e = fragment; - } else { - e = query; - } - } else if (query) { - e = query; - } else if (fragment) { - e = fragment; - } - } else { - e = p; - } + e = s + strcspn(s, "/?#"); /* check for login and password */ if ((p = zend_memrchr(s, '@', (e-s)))) {