1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/uri: Fix the distinction between an empty and a missing query/fragment for WHATWG URLs (#20208)

This commit is contained in:
Máté Kocsis
2025-11-11 17:05:13 +01:00
committed by GitHub
parent 8a0c300d02
commit 88285c3333
3 changed files with 5 additions and 5 deletions

View File

@@ -15,5 +15,5 @@ var_dump($url2->toAsciiString());
?>
--EXPECT--
NULL
NULL
string(0) ""
string(21) "https://example.com/#"

View File

@@ -15,5 +15,5 @@ var_dump($url2->toAsciiString());
?>
--EXPECT--
NULL
NULL
string(0) ""
string(21) "https://example.com/?"

View File

@@ -431,7 +431,7 @@ static zend_result php_uri_parser_whatwg_path_read(void *uri, php_uri_component_
{
const lxb_url_t *lexbor_uri = uri;
if (lexbor_uri->path.str.length) {
if (lexbor_uri->path.str.length > 0) {
ZVAL_STRINGL(retval, (const char *) lexbor_uri->path.str.data, lexbor_uri->path.str.length);
} else {
ZVAL_EMPTY_STRING(retval);
@@ -460,7 +460,7 @@ static zend_result php_uri_parser_whatwg_query_read(void *uri, php_uri_component
{
const lxb_url_t *lexbor_uri = uri;
if (lexbor_uri->query.length) {
if (lexbor_uri->query.data != NULL) {
ZVAL_STRINGL(retval, (const char *) lexbor_uri->query.data, lexbor_uri->query.length);
} else {
ZVAL_NULL(retval);
@@ -489,7 +489,7 @@ static zend_result php_uri_parser_whatwg_fragment_read(void *uri, php_uri_compon
{
const lxb_url_t *lexbor_uri = uri;
if (lexbor_uri->fragment.length) {
if (lexbor_uri->fragment.data != NULL) {
ZVAL_STRINGL(retval, (const char *) lexbor_uri->fragment.data, lexbor_uri->fragment.length);
} else {
ZVAL_NULL(retval);