Skip to content

Commit d6ab0c3

Browse files
committed
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.
1 parent 5d5305d commit d6ab0c3

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

ext/uri/uri_parser_rfc3986.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -341,19 +341,15 @@ void *php_uri_parser_rfc3986_parse(const char *uri_str, size_t uri_str_len, cons
341341
return php_uri_parser_rfc3986_parse_ex(uri_str, uri_str_len, base_url, silent);
342342
}
343343

344-
/* When calling a wither successfully, the normalized URI is surely invalidated, therefore
345-
* it doesn't make sense to copy it. In case of failure, an exception is thrown, and the URI object
346-
* is discarded altogether. */
347344
ZEND_ATTRIBUTE_NONNULL static void *php_uri_parser_rfc3986_clone(void *uri)
348345
{
349346
const php_uri_parser_rfc3986_uris *uriparser_uris = uri;
350347

351348
php_uri_parser_rfc3986_uris *new_uriparser_uris = uriparser_create_uris();
352349
copy_uri(&new_uriparser_uris->uri, &uriparser_uris->uri);
353-
if (uriparser_uris->normalized_uri_initialized) {
354-
copy_uri(&new_uriparser_uris->normalized_uri, &uriparser_uris->normalized_uri);
355-
new_uriparser_uris->normalized_uri_initialized = true;
356-
}
350+
/* Do not copy the normalized URI: The expected action after cloning is
351+
* modifying the cloned URL (which will invalidate the cached normalized
352+
* URI). */
357353

358354
return new_uriparser_uris;
359355
}

0 commit comments

Comments
 (0)