diff --git a/ext/standard/tests/url/gh12703.phpt b/ext/standard/tests/url/gh12703.phpt new file mode 100644 index 0000000000000..88dd3de1434cd --- /dev/null +++ b/ext/standard/tests/url/gh12703.phpt @@ -0,0 +1,43 @@ +--TEST-- +GH-12703 parse_url() return false on absolute path containing ':' and no query string. +--FILE-- + +--EXPECT-- +array(1) { + ["path"]=> + string(7) "/page:1" +} +NULL +array(2) { + ["path"]=> + string(7) "/page:1" + ["query"]=> + string(7) "foo=bar" +} +array(2) { + ["host"]=> + string(14) "www.examle.com" + ["path"]=> + string(11) "/foo:65535/" +} +array(3) { + ["host"]=> + string(14) "www.examle.com" + ["port"]=> + int(8080) + ["path"]=> + string(11) "/foo:65535/" +} diff --git a/ext/standard/url.c b/ext/standard/url.c index e3d95768fb019..eb4d59d2191bf 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -118,7 +118,7 @@ PHPAPI php_url *php_url_parse_ex2(char const *str, size_t length, bool *has_port while (p < e) { /* scheme = 1*[ lowalpha | digit | "+" | "-" | "." ] */ if (!isalpha(*p) && !isdigit(*p) && *p != '+' && *p != '.' && *p != '-') { - if (e + 1 < ue && e < binary_strcspn(s, ue, "?#")) { + if (*s != '/' && e + 1 < ue && e < binary_strcspn(s, ue, "?#")) { goto parse_port; } else if (s + 1 < ue && *s == '/' && *(s + 1) == '/') { /* relative-scheme URL */ s += 2;