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

uri: Do not copy the normalized URI when cloning RFC 3986 URIs (#19588)

* uri: Do not copy the normalized URI when cloning RFC 3986 URIs

The with-ers are not yet implemented for RFC 3986, the argument in the comment
however makes sense and the implementation did not match the comment.

* uri: Fix typo in comment in uri_parser_rfc3986.c

Co-authored-by: Máté Kocsis <kocsismate90@gmail.com>

---------

Co-authored-by: Máté Kocsis <kocsismate90@gmail.com>
This commit is contained in:
Tim Düsterhus
2025-09-07 15:26:21 +02:00
committed by GitHub
parent b5817cc4c3
commit c267652d69

View File

@@ -353,19 +353,15 @@ void *php_uri_parser_rfc3986_parse(const char *uri_str, size_t uri_str_len, cons
return php_uri_parser_rfc3986_parse_ex(uri_str, uri_str_len, base_url, silent);
}
/* When calling a wither successfully, the normalized URI is surely invalidated, therefore
* it doesn't make sense to copy it. In case of failure, an exception is thrown, and the URI object
* is discarded altogether. */
ZEND_ATTRIBUTE_NONNULL static void *php_uri_parser_rfc3986_clone(void *uri)
{
const php_uri_parser_rfc3986_uris *uriparser_uris = uri;
php_uri_parser_rfc3986_uris *new_uriparser_uris = uriparser_create_uris();
copy_uri(&new_uriparser_uris->uri, &uriparser_uris->uri);
if (uriparser_uris->normalized_uri_initialized) {
copy_uri(&new_uriparser_uris->normalized_uri, &uriparser_uris->normalized_uri);
new_uriparser_uris->normalized_uri_initialized = true;
}
/* Do not copy the normalized URI: The expected action after cloning is
* modifying the cloned URI (which will invalidate the cached normalized
* URI). */
return new_uriparser_uris;
}