Skip to content

Commit 8bbca6c

Browse files
committed
uri: Allow empty URIs for RFC3986
1 parent 7e2ba9d commit 8bbca6c

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

ext/uri/php_uriparser.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,6 @@ void *uriparser_parse_uri_ex(const zend_string *uri_str, const uriparser_uris_t
296296
{
297297
UriUriA uri = {0};
298298

299-
/* Empty URIs are always invalid. */
300-
if (ZSTR_LEN(uri_str) == 0) {
301-
if (!silent) {
302-
zend_throw_exception(uri_invalid_uri_exception_ce, "The specified URI must not be empty", 0);
303-
}
304-
305-
goto fail;
306-
}
307-
308299
/* Parse the URI. */
309300
if (uriParseSingleUriExMmA(&uri, ZSTR_VAL(uri_str), ZSTR_VAL(uri_str) + ZSTR_LEN(uri_str), NULL, mm) != URI_SUCCESS) {
310301
if (!silent) {

ext/uri/tests/004.phpt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,24 @@ var_dump(Uri\WhatWg\Url::parse("http://RuPaul's Drag Race All Stars 7 Winners Ca
2929

3030
?>
3131
--EXPECTF--
32-
The specified URI must not be empty
33-
NULL
32+
object(Uri\Rfc3986\Uri)#1 (8) {
33+
["scheme"]=>
34+
NULL
35+
["username"]=>
36+
NULL
37+
["password"]=>
38+
NULL
39+
["host"]=>
40+
NULL
41+
["port"]=>
42+
NULL
43+
["path"]=>
44+
string(0) ""
45+
["query"]=>
46+
NULL
47+
["fragment"]=>
48+
NULL
49+
}
3450
The specified URI is malformed (MissingSchemeNonRelativeUrl)
3551
NULL
3652
object(Uri\Rfc3986\Uri)#%d (%d) {

0 commit comments

Comments
 (0)