diff --git a/ext/uri/tests/rfc3986/parsing/userinfo_success_empty.phpt b/ext/uri/tests/rfc3986/parsing/userinfo_success_empty.phpt new file mode 100644 index 00000000000..8b7df6c55ca --- /dev/null +++ b/ext/uri/tests/rfc3986/parsing/userinfo_success_empty.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test Uri\Rfc3986\Uri parsing - userinfo - empty +--EXTENSIONS-- +uri +--FILE-- +toRawString()); +var_dump($uri->toString()); + +?> +--EXPECTF-- +object(Uri\Rfc3986\Uri)#%d (%d) { + ["scheme"]=> + string(5) "https" + ["username"]=> + string(0) "" + ["password"]=> + string(0) "" + ["host"]=> + string(11) "example.com" + ["port"]=> + NULL + ["path"]=> + string(0) "" + ["query"]=> + NULL + ["fragment"]=> + NULL +} +string(20) "https://@example.com" +string(20) "https://@example.com" diff --git a/ext/uri/tests/rfc3986/parsing/userinfo_success_only_password.phpt b/ext/uri/tests/rfc3986/parsing/userinfo_success_only_password.phpt new file mode 100644 index 00000000000..eb5053c1049 --- /dev/null +++ b/ext/uri/tests/rfc3986/parsing/userinfo_success_only_password.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test Uri\Rfc3986\Uri parsing - userinfo - only password +--EXTENSIONS-- +uri +--FILE-- +toRawString()); +var_dump($uri->toString()); + +?> +--EXPECTF-- +object(Uri\Rfc3986\Uri)#%d (%d) { + ["scheme"]=> + string(5) "https" + ["username"]=> + string(0) "" + ["password"]=> + string(4) "pass" + ["host"]=> + string(11) "example.com" + ["port"]=> + NULL + ["path"]=> + string(0) "" + ["query"]=> + NULL + ["fragment"]=> + NULL +} +string(25) "https://:pass@example.com" +string(25) "https://:pass@example.com" diff --git a/ext/uri/tests/rfc3986/parsing/userinfo_success_only_username.phpt b/ext/uri/tests/rfc3986/parsing/userinfo_success_only_username.phpt new file mode 100644 index 00000000000..1081a0e0485 --- /dev/null +++ b/ext/uri/tests/rfc3986/parsing/userinfo_success_only_username.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test Uri\Rfc3986\Uri parsing - userinfo - only username +--EXTENSIONS-- +uri +--FILE-- +toRawString()); +var_dump($uri->toString()); + +?> +--EXPECTF-- +object(Uri\Rfc3986\Uri)#%d (%d) { + ["scheme"]=> + string(5) "https" + ["username"]=> + string(4) "user" + ["password"]=> + string(0) "" + ["host"]=> + string(11) "example.com" + ["port"]=> + NULL + ["path"]=> + string(0) "" + ["query"]=> + NULL + ["fragment"]=> + NULL +} +string(25) "https://user:@example.com" +string(25) "https://user:@example.com" diff --git a/ext/uri/uri_parser_rfc3986.c b/ext/uri/uri_parser_rfc3986.c index a24fb467bf3..69bd6ef9ecd 100644 --- a/ext/uri/uri_parser_rfc3986.c +++ b/ext/uri/uri_parser_rfc3986.c @@ -202,7 +202,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_username_read(v } else if (c != NULL && c - uriparser_uri->userInfo.first > 0) { ZVAL_STRINGL(retval, uriparser_uri->userInfo.first, c - uriparser_uri->userInfo.first); } else { - ZVAL_NULL(retval); + ZVAL_EMPTY_STRING(retval); } } else { ZVAL_NULL(retval); @@ -221,7 +221,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result php_uri_parser_rfc3986_password_read(v if (c != NULL && uriparser_uri->userInfo.afterLast - c - 1 > 0) { ZVAL_STRINGL(retval, c + 1, uriparser_uri->userInfo.afterLast - c - 1); } else { - ZVAL_NULL(retval); + ZVAL_EMPTY_STRING(retval); } } else { ZVAL_NULL(retval);