summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorIngo Walz <ingo.walz@googlemail.com>2013-11-23 02:31:23 +0100
committerStanislav Malyshev <stas@php.net>2014-04-13 18:37:40 -0700
commitb05c088a3abf8e4c6fb6e40418423a9e2dd3d929 (patch)
treeb5b54359638d70d072fcb288ba2a4ef1546383ad /ext
parent5558d0db9b88a1975b40d4beb5db863c7d87e3c0 (diff)
downloadphp-git-b05c088a3abf8e4c6fb6e40418423a9e2dd3d929.tar.gz
Fixed bug #64604
Diffstat (limited to 'ext')
-rw-r--r--ext/standard/tests/url/bug64604.phpt40
-rw-r--r--ext/standard/url.c8
2 files changed, 44 insertions, 4 deletions
diff --git a/ext/standard/tests/url/bug64604.phpt b/ext/standard/tests/url/bug64604.phpt
new file mode 100644
index 0000000000..bbc3cb9d1b
--- /dev/null
+++ b/ext/standard/tests/url/bug64604.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #64604 parse_url is inconsistent with specified port
+--FILE--
+<?php
+var_dump(parse_url('//localhost/path'));
+var_dump(parse_url('//localhost:80/path'));
+var_dump(parse_url('//localhost:/path'));
+var_dump(parse_url('http://localhost:80/path'));
+?>
+--EXPECT--
+array(2) {
+ ["host"]=>
+ string(9) "localhost"
+ ["path"]=>
+ string(5) "/path"
+}
+array(3) {
+ ["host"]=>
+ string(9) "localhost"
+ ["port"]=>
+ int(80)
+ ["path"]=>
+ string(5) "/path"
+}
+array(2) {
+ ["host"]=>
+ string(9) "localhost"
+ ["path"]=>
+ string(5) "/path"
+}
+array(4) {
+ ["scheme"]=>
+ string(4) "http"
+ ["host"]=>
+ string(9) "localhost"
+ ["port"]=>
+ int(80)
+ ["path"]=>
+ string(5) "/path"
+}
diff --git a/ext/standard/url.c b/ext/standard/url.c
index d8271a18ed..16237e6599 100644
--- a/ext/standard/url.c
+++ b/ext/standard/url.c
@@ -181,6 +181,10 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
p = e + 1;
pp = p;
+ if (*s == '/' && *(s+1) == '/') { /* relative-scheme URL */
+ s += 2;
+ }
+
while (pp-p < 6 && isdigit(*pp)) {
pp++;
}
@@ -201,10 +205,6 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
STR_FREE(ret->scheme);
efree(ret);
return NULL;
- } else if (*s == '/' && *(s+1) == '/') { /* relative-scheme URL */
- s += 2;
- } else {
- goto just_path;
}
} else if (*s == '/' && *(s+1) == '/') { /* relative-scheme URL */
s += 2;