Skip to content
Permalink
Browse files

Fixed bug #68917 (parse_url fails on some partial urls)

  • Loading branch information...
datibbaw committed Mar 6, 2015
1 parent e892f53 commit d7fb52ea20aba5c9ef53dfa57af3b62717c9e9e5
Showing with 30 additions and 2 deletions.
  1. +2 −0 NEWS
  2. +23 −0 ext/standard/tests/url/bug68917.phpt
  3. +5 −2 ext/standard/url.c
2 NEWS
@@ -2,6 +2,8 @@ PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2015, PHP 5.5.24

- Core:
. Fixed bug #68917 (parse_url fails on some partial urls). (Wei Dai)

19 Mar 2015, PHP 5.5.23

@@ -0,0 +1,23 @@
--TEST--
Bug #68917 (parse_url fails on some partial urls)
--FILE--
<?php
print_r(parse_url('//example.org:81/hi?a=b#c=d'));
print_r(parse_url('//example.org/hi?a=b#c=d'));
?>
--EXPECT--
Array
(
[host] => example.org
[port] => 81
[path] => /hi
[query] => a=b
[fragment] => c=d
)
Array
(
[host] => example.org
[path] => /hi
[query] => a=b
[fragment] => c=d
)
@@ -192,6 +192,9 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
port = strtol(port_buf, NULL, 10);
if (port > 0 && port <= 65535) {
ret->port = (unsigned short) port;
if (*s == '/' && *(s + 1) == '/') { /* relative-scheme URL */
s += 2;
}
} else {
STR_FREE(ret->scheme);
efree(ret);
@@ -201,12 +204,12 @@ 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 */
} else if (*s == '/' && *(s + 1) == '/') { /* relative-scheme URL */
s += 2;
} else {
goto just_path;
}
} else if (*s == '/' && *(s+1) == '/') { /* relative-scheme URL */
} else if (*s == '/' && *(s + 1) == '/') { /* relative-scheme URL */
s += 2;
} else {
just_path:

0 comments on commit d7fb52e

Please sign in to comment.
You can’t perform that action at this time.