summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikic@php.net>2016-10-08 01:04:22 +0200
committerNikita Popov <nikic@php.net>2016-10-08 01:04:22 +0200
commitb061fa909de77085d3822a89ab901b934d0362c4 (patch)
treec0715b964e220144086a49daa388a1d80ae46e5d
parentbc3a0b82b82e54dabe688dcc37f8ada92771da0f (diff)
downloadphp-git-b061fa909de77085d3822a89ab901b934d0362c4.tar.gz
Fix bug #73192
-rw-r--r--ext/standard/tests/url/bug73192.phpt30
-rw-r--r--ext/standard/tests/url/parse_url_basic_001.phpt20
-rw-r--r--ext/standard/tests/url/parse_url_basic_002.phpt4
-rw-r--r--ext/standard/tests/url/parse_url_basic_003.phpt4
-rw-r--r--ext/standard/tests/url/parse_url_basic_004.phpt4
-rw-r--r--ext/standard/tests/url/parse_url_basic_005.phpt4
-rw-r--r--ext/standard/tests/url/parse_url_basic_006.phpt4
-rw-r--r--ext/standard/tests/url/parse_url_basic_007.phpt4
-rw-r--r--ext/standard/tests/url/parse_url_basic_008.phpt4
-rw-r--r--ext/standard/tests/url/parse_url_basic_009.phpt4
-rw-r--r--ext/standard/url.c23
11 files changed, 49 insertions, 56 deletions
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--
+<?php
+
+var_dump(parse_url("http://example.com:80#@google.com/"));
+var_dump(parse_url("http://example.com:80?@google.com/"));
+
+?>
+--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)))) {