mirror of
https://github.com/php/php-src.git
synced 2024-11-24 18:34:21 +08:00
Fixed bug #32813 (parse_url() does not handle scheme-only urls properly).
This commit is contained in:
parent
87fc464c6b
commit
8281f41f3e
@ -67,7 +67,8 @@ $sample_urls = array (
|
||||
'file://path/to/file',
|
||||
'file:/path/to/file',
|
||||
'http://1.2.3.4:/abc.asp?a=1&b=2',
|
||||
'http://foo.com#bar'
|
||||
'http://foo.com#bar',
|
||||
'scheme:'
|
||||
);
|
||||
|
||||
foreach ($sample_urls as $url) {
|
||||
@ -657,3 +658,7 @@ array(3) {
|
||||
["fragment"]=>
|
||||
string(3) "bar"
|
||||
}
|
||||
array(1) {
|
||||
["scheme"]=>
|
||||
string(6) "scheme"
|
||||
}
|
||||
|
@ -104,6 +104,12 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
|
||||
|
||||
/* parse scheme */
|
||||
if ((e = memchr(s, ':', length)) && (e - s)) {
|
||||
if (*(e + 1) == '\0') { /* only scheme is available */
|
||||
ret->scheme = estrndup(s, (e - s));
|
||||
php_replace_controlchars_ex(ret->scheme, (e - s));
|
||||
goto end;
|
||||
}
|
||||
|
||||
/*
|
||||
* certain schemas like mailto: and zlib: may not have any / after them
|
||||
* this check ensures we support those.
|
||||
@ -303,7 +309,7 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
|
||||
ret->path = estrndup(s, (ue-s));
|
||||
php_replace_controlchars_ex(ret->path, (ue - s));
|
||||
}
|
||||
|
||||
end:
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
Loading…
Reference in New Issue
Block a user