From c267652d699891b31dabc5ad36f3988d943ed315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Sun, 7 Sep 2025 15:26:21 +0200 Subject: [PATCH] uri: Do not copy the normalized URI when cloning RFC 3986 URIs (#19588) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --------- Co-authored-by: Máté Kocsis --- ext/uri/uri_parser_rfc3986.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ext/uri/uri_parser_rfc3986.c b/ext/uri/uri_parser_rfc3986.c index 7a004a41b0a..70e0eaae1f0 100644 --- a/ext/uri/uri_parser_rfc3986.c +++ b/ext/uri/uri_parser_rfc3986.c @@ -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; }