From b05c088a3abf8e4c6fb6e40418423a9e2dd3d929 Mon Sep 17 00:00:00 2001 From: Ingo Walz Date: Sat, 23 Nov 2013 02:31:23 +0100 Subject: Fixed bug #64604 --- NEWS | 2 ++ ext/standard/tests/url/bug64604.phpt | 40 ++++++++++++++++++++++++++++++++++++ ext/standard/url.c | 8 ++++---- 3 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 ext/standard/tests/url/bug64604.phpt diff --git a/NEWS b/NEWS index c6522aea91..d04e961a31 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,8 @@ PHP NEWS . Fixed bug #61019 (Out of memory on command stream_get_contents). (Mike) . Fixed bug #64330 (stream_socket_server() creates wrong Abstract Namespace UNIX sockets). (Mike) + . Fixed bug #64604 (parse_url is inconsistent with specified port). + (Ingo Walz) . Fixed bug #66182 (exit in stream filter produces segfault). (Mike) . Fixed bug #66736 (fpassthru broken). (Mike) . Fixed bug #67024 (getimagesize should recognize BMP files with negative 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-- + +--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; -- cgit v1.2.1