com php-src: Fixed bug 64604: ext/standard/tests/url/bug64604.phpt ext/standard/url.c
| From: | Stanislav Malyshev | Date: | Sat, 23 Nov 2013 01:31:23 +0000 |
| Subject: | com php-src: Fixed bug 64604: ext/standard/tests/url/bug64604.phpt ext/standard/url.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76862@lists.php.net to get a copy of this message | ||
Commit: 880ecd603c764698e2d08f2a28617259b3287b62
Author: Ingo Walz <ingo.walz@googlemail.com> Sat, 23 Nov 2013 02:31:23 +0100
Parents: 345032946c9143d0d343ef1b5de12b6130780fdf
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=880ecd603c764698e2d08f2a28617259b3287b62
Log:
Fixed bug 64604
Bugs:
https://bugs.php.net/64604
Changed paths:
A ext/standard/tests/url/bug64604.phpt
M ext/standard/url.c
Diff:
diff --git a/ext/standard/tests/url/bug64604.phpt b/ext/standard/tests/url/bug64604.phpt
new file mode 100644
index 0000000..bbc3cb9
--- /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 190b466..bd4887c 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;