1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00

Merge branch 'PHP-7.4' into master

* PHP-7.4:
  Fix #80114: parse_url does not accept URLs with port 0
This commit is contained in:
Christoph M. Becker
2020-09-20 15:38:18 +02:00
12 changed files with 33 additions and 4 deletions

View File

@@ -873,6 +873,15 @@ echo "Done";
string(3) "%:x"
}
--> https://example.com:0/: array(3) {
["scheme"]=>
string(5) "https"
["host"]=>
string(11) "example.com"
["path"]=>
string(1) "/"
}
--> http:///blah.com: bool(false)
--> http://:80: bool(false)

View File

@@ -107,6 +107,7 @@ echo "Done";
--> / : NULL
--> /rest/Users?filter={"id":"123"} : NULL
--> %:x : NULL
--> https://example.com:0/ : string(5) "https"
--> http:///blah.com : bool(false)
--> http://:80 : bool(false)
--> http://user@:80 : bool(false)

View File

@@ -106,6 +106,7 @@ echo "Done";
--> / : NULL
--> /rest/Users?filter={"id":"123"} : NULL
--> %:x : NULL
--> https://example.com:0/ : string(11) "example.com"
--> http:///blah.com : bool(false)
--> http://:80 : bool(false)
--> http://user@:80 : bool(false)

View File

@@ -106,6 +106,7 @@ echo "Done";
--> / : NULL
--> /rest/Users?filter={"id":"123"} : NULL
--> %:x : NULL
--> https://example.com:0/ : NULL
--> http:///blah.com : bool(false)
--> http://:80 : bool(false)
--> http://user@:80 : bool(false)

View File

@@ -106,6 +106,7 @@ echo "Done";
--> / : NULL
--> /rest/Users?filter={"id":"123"} : NULL
--> %:x : NULL
--> https://example.com:0/ : NULL
--> http:///blah.com : bool(false)
--> http://:80 : bool(false)
--> http://user@:80 : bool(false)

View File

@@ -106,6 +106,7 @@ echo "Done";
--> / : NULL
--> /rest/Users?filter={"id":"123"} : NULL
--> %:x : NULL
--> https://example.com:0/ : NULL
--> http:///blah.com : bool(false)
--> http://:80 : bool(false)
--> http://user@:80 : bool(false)

View File

@@ -106,6 +106,7 @@ echo "Done";
--> / : string(1) "/"
--> /rest/Users?filter={"id":"123"} : string(11) "/rest/Users"
--> %:x : string(3) "%:x"
--> https://example.com:0/ : string(1) "/"
--> http:///blah.com : bool(false)
--> http://:80 : bool(false)
--> http://user@:80 : bool(false)

View File

@@ -106,6 +106,7 @@ echo "Done";
--> / : NULL
--> /rest/Users?filter={"id":"123"} : string(19) "filter={"id":"123"}"
--> %:x : NULL
--> https://example.com:0/ : NULL
--> http:///blah.com : bool(false)
--> http://:80 : bool(false)
--> http://user@:80 : bool(false)

View File

@@ -106,6 +106,7 @@ echo "Done";
--> / : NULL
--> /rest/Users?filter={"id":"123"} : NULL
--> %:x : NULL
--> https://example.com:0/ : NULL
--> http:///blah.com : bool(false)
--> http://:80 : bool(false)
--> http://user@:80 : bool(false)

View File

@@ -881,6 +881,15 @@ echo "Done";
string(3) "%:x"
}
--> https://example.com:0/: array(3) {
["scheme"]=>
string(5) "https"
["host"]=>
string(11) "example.com"
["path"]=>
string(1) "/"
}
--> http:///blah.com: bool(false)
--> http://:80: bool(false)

View File

@@ -92,6 +92,7 @@ $urls = array(
'/',
'/rest/Users?filter={"id":"123"}',
'%:x',
'https://example.com:0/',
// Severely malformed URLs that do not parse:
'http:///blah.com',

View File

@@ -183,10 +183,11 @@ PHPAPI php_url *php_url_parse_ex(char const *str, size_t length)
if (pp - p > 0 && pp - p < 6 && (pp == ue || *pp == '/')) {
zend_long port;
char *end;
memcpy(port_buf, p, (pp - p));
port_buf[pp - p] = '\0';
port = ZEND_STRTOL(port_buf, NULL, 10);
if (port > 0 && port <= 65535) {
port = ZEND_STRTOL(port_buf, &end, 10);
if (port >= 0 && port <= 65535 && end != port_buf) {
ret->port = (unsigned short) port;
if (s + 1 < ue && *s == '/' && *(s + 1) == '/') { /* relative-scheme URL */
s += 2;
@@ -247,10 +248,11 @@ parse_host:
return NULL;
} else if (e - p > 0) {
zend_long port;
char *end;
memcpy(port_buf, p, (e - p));
port_buf[e - p] = '\0';
port = ZEND_STRTOL(port_buf, NULL, 10);
if (port > 0 && port <= 65535) {
port = ZEND_STRTOL(port_buf, &end, 10);
if (port >= 0 && port <= 65535 && end != port_buf) {
ret->port = (unsigned short)port;
} else {
php_url_free(ret);