diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index 2dc4cc76b8ca4..2c64de3f58724 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -608,14 +608,14 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ int parser_name_set; FETCH_STR_OPTION(parser_name, URL_OPTION_URI_PARSER_CLASS); - uri_handler_t *uri_handler = php_uri_get_handler(parser_name_set ? parser_name : NULL); - if (uri_handler == NULL) { + uri_parser_t *uri_parser = php_uri_get_parser(parser_name_set ? parser_name : NULL); + if (uri_parser == NULL) { zend_value_error("%s(): \"uri_parser_class\" option has invalid value", get_active_function_name()); RETURN_VALIDATION_FAILED } /* Parse the URI - if it fails, we return NULL */ - php_uri *uri = php_uri_parse_to_struct(uri_handler, Z_STRVAL_P(value), Z_STRLEN_P(value), URI_COMPONENT_READ_RAW, true); + php_uri *uri = php_uri_parse_to_struct(uri_parser, Z_STRVAL_P(value), Z_STRLEN_P(value), URI_COMPONENT_READ_RAW, true); if (uri == NULL) { RETURN_VALIDATION_FAILED } @@ -630,7 +630,7 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ if ( /* Skipping these checks is possible because the new URI implementations perform comprehensive validations. */ - strcmp(uri_handler->name, URI_PARSER_PHP) == 0 && + strcmp(uri_parser->name, URI_PARSER_PHP) == 0 && /* An IPv6 enclosed by square brackets is a valid hostname.*/ !php_filter_is_valid_ipv6_hostname(uri->host) && /* Validate domain. @@ -651,7 +651,7 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ RETURN_VALIDATION_FAILED } - if (strcmp(uri_handler->name, URI_PARSER_PHP) == 0 && + if (strcmp(uri_parser->name, URI_PARSER_PHP) == 0 && ( (uri->user != NULL && !is_userinfo_valid(uri->user)) || (uri->password != NULL && !is_userinfo_valid(uri->password)) diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index 7c39d949a1738..6fbdb506133c7 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -2634,13 +2634,13 @@ static char *php_openssl_get_url_name(const char *resourcename, return NULL; } - uri_handler_t *uri_handler = php_stream_context_get_uri_handler("ssl", context); - if (uri_handler == NULL) { + uri_parser_t *uri_parser = php_stream_context_get_uri_parser("ssl", context); + if (uri_parser == NULL) { zend_value_error("%s(): Provided stream context has invalid value for the \"uri_parser_class\" option", get_active_function_name()); return NULL; } - uri_internal_t *internal_uri = php_uri_parse(uri_handler, resourcename, resourcenamelen, true); + uri_internal_t *internal_uri = php_uri_parse(uri_parser, resourcename, resourcenamelen, true); if (internal_uri == NULL) { return NULL; } diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 1afa401d5c606..854db4c928cbf 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -431,12 +431,12 @@ int make_http_soap_request( } if (location != NULL && ZSTR_VAL(location)[0] != '\000') { - uri_handler_t *uri_handler = php_uri_get_handler(uri_parser_class); - if (uri_handler == NULL) { + uri_parser_t *uri_parser = php_uri_get_parser(uri_parser_class); + if (uri_parser == NULL) { zend_argument_value_error(6, "must be a valid URI parser name"); return FALSE; } - uri = php_uri_parse_to_struct(uri_handler, ZSTR_VAL(location), ZSTR_LEN(location), URI_COMPONENT_READ_RAW, true); + uri = php_uri_parse_to_struct(uri_parser, ZSTR_VAL(location), ZSTR_LEN(location), URI_COMPONENT_READ_RAW, true); } tmp = Z_CLIENT_STREAM_CONTEXT_P(this_ptr); @@ -1148,14 +1148,14 @@ int make_http_soap_request( char *loc; if ((loc = get_http_header_value(ZSTR_VAL(http_headers), "Location:")) != NULL) { - uri_handler_t *uri_handler = php_uri_get_handler(uri_parser_class); - if (uri_handler == NULL) { + uri_parser_t *uri_parser = php_uri_get_parser(uri_parser_class); + if (uri_parser == NULL) { efree(loc); zend_argument_value_error(6, "must be a valid URI parser name"); return FALSE; } - php_uri *new_uri = php_uri_parse_to_struct(uri_handler, loc, strlen(loc), URI_COMPONENT_READ_RAW, true); + php_uri *new_uri = php_uri_parse_to_struct(uri_parser, loc, strlen(loc), URI_COMPONENT_READ_RAW, true); efree(loc); if (new_uri != NULL) { diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index 07b8251d0708e..0a3b261d39c24 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -135,13 +135,13 @@ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, const char char *transport; int transport_len; - uri_handler_t *uri_handler = php_stream_context_get_uri_handler("ftp", context); - if (uri_handler == NULL) { + uri_parser_t *uri_parser = php_stream_context_get_uri_parser("ftp", context); + if (uri_parser == NULL) { zend_value_error("%s(): Provided stream context has invalid value for the \"uri_parser_class\" option", get_active_function_name()); return NULL; } - resource = php_uri_parse_to_struct(uri_handler, path, strlen(path), URI_COMPONENT_READ_RAW, true); + resource = php_uri_parse_to_struct(uri_parser, path, strlen(path), URI_COMPONENT_READ_RAW, true); if (resource == NULL || resource->path == NULL) { if (resource && presource) { *presource = resource; @@ -956,18 +956,18 @@ static int php_stream_ftp_rename(php_stream_wrapper *wrapper, const char *url_fr int result; char tmp_line[512]; - uri_handler_t *uri_handler = php_stream_context_get_uri_handler("ftp", context); - if (uri_handler == NULL) { + uri_parser_t *uri_parser = php_stream_context_get_uri_parser("ftp", context); + if (uri_parser == NULL) { zend_value_error("%s(): Provided stream context has invalid value for the \"uri_parser_class\" option", get_active_function_name()); return 0; } - resource_from = php_uri_parse_to_struct(uri_handler, url_from, strlen(url_from), URI_COMPONENT_READ_RAW, true); + resource_from = php_uri_parse_to_struct(uri_parser, url_from, strlen(url_from), URI_COMPONENT_READ_RAW, true); if (!resource_from) { return 0; } - resource_to = php_uri_parse_to_struct(uri_handler, url_to, strlen(url_to), URI_COMPONENT_READ_RAW, true); + resource_to = php_uri_parse_to_struct(uri_parser, url_to, strlen(url_to), URI_COMPONENT_READ_RAW, true); if (!resource_to) { goto rename_errexit; } diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 9727f10c21f3d..81d688a2f0458 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -393,12 +393,12 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, return NULL; } - uri_handler_t *uri_handler = php_stream_context_get_uri_handler("http", context); - if (uri_handler == NULL) { + uri_parser_t *uri_parser = php_stream_context_get_uri_parser("http", context); + if (uri_parser == NULL) { zend_value_error("%s(): Provided stream context has invalid value for the \"uri_parser_class\" option", get_active_function_name()); return NULL; } - resource = php_uri_parse_to_struct(uri_handler, path, strlen(path), URI_COMPONENT_READ_RAW, true); + resource = php_uri_parse_to_struct(uri_parser, path, strlen(path), URI_COMPONENT_READ_RAW, true); if (resource == NULL) { return NULL; } @@ -1097,7 +1097,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, php_uri_struct_free(resource); /* check for invalid redirection URLs */ - if ((resource = php_uri_parse_to_struct(uri_handler, new_path, strlen(new_path), URI_COMPONENT_READ_RAW, true)) == NULL) { + if ((resource = php_uri_parse_to_struct(uri_parser, new_path, strlen(new_path), URI_COMPONENT_READ_RAW, true)) == NULL) { php_stream_wrapper_log_error(wrapper, options, "Invalid redirect URL! %s", new_path); efree(new_path); goto out; diff --git a/ext/standard/url.c b/ext/standard/url.c index d19965fb2081c..dfd5fa46ccc0c 100644 --- a/ext/standard/url.c +++ b/ext/standard/url.c @@ -463,7 +463,7 @@ static void *parse_url_parse_uri(const char *uri_str, size_t uri_str_len, const return url; } -const uri_handler_t parse_url_uri_handler = { +const uri_parser_t parse_url_uri_parser = { .name = URI_PARSER_PHP, .parse_uri = parse_url_parse_uri, .clone_uri = NULL, @@ -924,5 +924,5 @@ PHP_FUNCTION(get_headers) PHP_MINIT_FUNCTION(url) { - return php_uri_handler_register(&parse_url_uri_handler); + return php_uri_parser_register(&parse_url_uri_parser); } diff --git a/ext/uri/config.m4 b/ext/uri/config.m4 index 2f5a7a489b5ae..a43505e2ca9eb 100644 --- a/ext/uri/config.m4 +++ b/ext/uri/config.m4 @@ -2,10 +2,10 @@ dnl Configure options dnl PHP_INSTALL_HEADERS([ext/uri], m4_normalize([ - php_lexbor.h php_uri.h php_uri_common.h - php_uriparser.h + uri_parser_rfc3986.h + uri_parser_whatwg.h ])) AC_DEFINE([URI_ENABLE_ANSI], [1], [Define to 1 for enabling ANSI support of uriparser.]) @@ -18,6 +18,6 @@ $URIPARSER_DIR/src/UriMemory.c $URIPARSER_DIR/src/UriNormalize.c $URIPARSER_DIR/ $URIPARSER_DIR/src/UriParse.c $URIPARSER_DIR/src/UriParseBase.c $URIPARSER_DIR/src/UriQuery.c \ $URIPARSER_DIR/src/UriRecompose.c $URIPARSER_DIR/src/UriResolve.c $URIPARSER_DIR/src/UriShorten.c" -PHP_NEW_EXTENSION(uri, [php_lexbor.c php_uri.c php_uri_common.c php_uriparser.c $URIPARSER_SOURCES], [no],,[-I$ext_srcdir/$URIPARSER_DIR/include -DURI_STATIC_BUILD -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) +PHP_NEW_EXTENSION(uri, [php_uri.c php_uri_common.c uri_parser_rfc3986.c uri_parser_whatwg.c $URIPARSER_SOURCES], [no],,[-I$ext_srcdir/$URIPARSER_DIR/include -DURI_STATIC_BUILD -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1]) PHP_ADD_EXTENSION_DEP(uri, lexbor) PHP_ADD_BUILD_DIR($ext_builddir/$URIPARSER_DIR/src $ext_builddir/$URIPARSER_DIR/include) diff --git a/ext/uri/config.w32 b/ext/uri/config.w32 index 6954ca06af555..c5ed6fdc17267 100644 --- a/ext/uri/config.w32 +++ b/ext/uri/config.w32 @@ -1,4 +1,4 @@ -EXTENSION("uri", "php_lexbor.c php_uri.c php_uri_common.c php_uriparser.c", false /* never shared */, "/I ext/lexbor /I ext/uri/uriparser/include /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); +EXTENSION("uri", "php_uri.c php_uri_common.c uri_parser_rfc3986.c uri_parser_whatwg.c ", false /* never shared */, "/I ext/lexbor /I ext/uri/uriparser/include /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1"); AC_DEFINE("URI_ENABLE_ANSI", 1, "Define to 1 for enabling ANSI support of uriparser.") AC_DEFINE("URI_NO_UNICODE", 1, "Define to 1 for disabling unicode support of uriparser.") @@ -6,4 +6,4 @@ ADD_FLAG("CFLAGS_URI", "/D URI_STATIC_BUILD"); ADD_EXTENSION_DEP('uri', 'lexbor'); ADD_SOURCES("ext/uri/uriparser/src", "UriCommon.c UriCompare.c UriCopy.c UriEscape.c UriFile.c UriIp4.c UriIp4Base.c UriMemory.c UriNormalize.c UriNormalizeBase.c UriParse.c UriParseBase.c UriQuery.c UriRecompose.c UriResolve.c UriShorten.c", "uri"); -PHP_INSTALL_HEADERS("ext/uri", "php_lexbor.h php_uri.h php_uri_common.h php_uriparser.h uriparser/src uriparser/include"); +PHP_INSTALL_HEADERS("ext/uri", "php_uri.h php_uri_common.h uri_parser_rfc3986.h uri_parser_whatwg.h uriparser/src uriparser/include"); diff --git a/ext/uri/php_uri.c b/ext/uri/php_uri.c index 708d7efe10fdd..595caafa5ac18 100644 --- a/ext/uri/php_uri.c +++ b/ext/uri/php_uri.c @@ -26,8 +26,8 @@ #include "ext/standard/info.h" #include "php_uri.h" -#include "php_lexbor.h" -#include "php_uriparser.h" +#include "uri_parser_whatwg.h" +#include "uri_parser_rfc3986.h" #include "php_uri_arginfo.h" #include "uriparser/src/UriConfig.h" @@ -49,11 +49,11 @@ static const zend_module_dep uri_deps[] = { ZEND_MOD_END }; -static zend_array uri_handlers; +static zend_array uri_parsers; -static uri_handler_t *uri_handler_by_name(const char *handler_name, size_t handler_name_len) +static uri_parser_t *uri_parser_by_name(const char *uri_parser_name, size_t uri_parser_name_len) { - return zend_hash_str_find_ptr(&uri_handlers, handler_name, handler_name_len); + return zend_hash_str_find_ptr(&uri_parsers, uri_parser_name, uri_parser_name_len); } static HashTable *uri_get_debug_properties(zend_object *object) @@ -68,7 +68,7 @@ static HashTable *uri_get_debug_properties(zend_object *object) return result; } - const uri_property_handlers_t property_handlers = internal_uri->handler->property_handlers; + const uri_property_handlers_t property_handlers = internal_uri->parser->property_handlers; zval tmp; if (property_handlers.scheme.read_func(internal_uri, URI_COMPONENT_READ_RAW, &tmp) == SUCCESS) { @@ -106,20 +106,20 @@ static HashTable *uri_get_debug_properties(zend_object *object) return result; } -PHPAPI uri_handler_t *php_uri_get_handler(const zend_string *uri_handler_name) +PHPAPI uri_parser_t *php_uri_get_parser(const zend_string *uri_parser_name) { - if (uri_handler_name == NULL) { - return uri_handler_by_name(URI_PARSER_PHP, sizeof(URI_PARSER_PHP) - 1); + if (uri_parser_name == NULL) { + return uri_parser_by_name(URI_PARSER_PHP, sizeof(URI_PARSER_PHP) - 1); } - return uri_handler_by_name(ZSTR_VAL(uri_handler_name), ZSTR_LEN(uri_handler_name)); + return uri_parser_by_name(ZSTR_VAL(uri_parser_name), ZSTR_LEN(uri_parser_name)); } -ZEND_ATTRIBUTE_NONNULL PHPAPI uri_internal_t *php_uri_parse(const uri_handler_t *uri_handler, const char *uri_str, size_t uri_str_len, bool silent) +ZEND_ATTRIBUTE_NONNULL PHPAPI uri_internal_t *php_uri_parse(const uri_parser_t *uri_parser, const char *uri_str, size_t uri_str_len, bool silent) { uri_internal_t *internal_uri = emalloc(sizeof(*internal_uri)); - internal_uri->handler = uri_handler; - internal_uri->uri = uri_handler->parse_uri(uri_str, uri_str_len, NULL, NULL, silent); + internal_uri->parser = uri_parser; + internal_uri->uri = uri_parser->parse_uri(uri_str, uri_str_len, NULL, NULL, silent); if (UNEXPECTED(internal_uri->uri == NULL)) { efree(internal_uri); @@ -185,16 +185,16 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_fragment(const uri_interna ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_free(uri_internal_t *internal_uri) { - internal_uri->handler->free_uri(internal_uri->uri); + internal_uri->parser->free_uri(internal_uri->uri); internal_uri->uri = NULL; - internal_uri->handler = NULL; + internal_uri->parser = NULL; efree(internal_uri); } ZEND_ATTRIBUTE_NONNULL PHPAPI php_uri *php_uri_parse_to_struct( - const uri_handler_t *uri_handler, const char *uri_str, size_t uri_str_len, uri_component_read_mode_t read_mode, bool silent + const uri_parser_t *uri_parser, const char *uri_str, size_t uri_str_len, uri_component_read_mode_t read_mode, bool silent ) { - uri_internal_t *uri_internal = php_uri_parse(uri_handler, uri_str, uri_str_len, silent); + uri_internal_t *uri_internal = php_uri_parse(uri_parser, uri_str, uri_str_len, silent); if (uri_internal == NULL) { return NULL; } @@ -336,8 +336,8 @@ static zend_result pass_errors_by_ref_and_free(zval *errors_zv, zval *errors) } ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2) PHPAPI void php_uri_instantiate_uri( - INTERNAL_FUNCTION_PARAMETERS, const uri_handler_t *handler, const zend_string *uri_str, const zend_object *base_url_object, - bool should_throw, bool should_update_this_object, zval *errors_zv + INTERNAL_FUNCTION_PARAMETERS, const uri_parser_t *uri_parser, const zend_string *uri_str, const zend_object *base_url_object, + bool should_throw, bool should_update_this_object, zval *errors_zv ) { zval errors; ZVAL_UNDEF(&errors); @@ -349,7 +349,7 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2) PHPAPI void php_uri_instantiate_uri( base_url = internal_base_url->uri; } - void *uri = handler->parse_uri(ZSTR_VAL(uri_str), ZSTR_LEN(uri_str), base_url, should_throw || errors_zv != NULL ? &errors : NULL, !should_throw); + void *uri = uri_parser->parse_uri(ZSTR_VAL(uri_str), ZSTR_LEN(uri_str), base_url, should_throw || errors_zv != NULL ? &errors : NULL, !should_throw); if (UNEXPECTED(uri == NULL)) { if (should_throw) { zval_ptr_dtor(&errors); @@ -378,7 +378,7 @@ ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2) PHPAPI void php_uri_instantiate_uri( uri_object = Z_URI_OBJECT_P(return_value); } - uri_object->internal.handler = handler; + uri_object->internal.parser = uri_parser; uri_object->internal.uri = uri; } @@ -393,7 +393,7 @@ static void create_rfc3986_uri(INTERNAL_FUNCTION_PARAMETERS, bool is_constructor Z_PARAM_OBJ_OF_CLASS_OR_NULL(base_url_object, uri_rfc3986_uri_ce) ZEND_PARSE_PARAMETERS_END(); - php_uri_instantiate_uri(INTERNAL_FUNCTION_PARAM_PASSTHRU, &uriparser_uri_handler, uri_str, base_url_object, is_constructor, is_constructor, NULL); + php_uri_instantiate_uri(INTERNAL_FUNCTION_PARAM_PASSTHRU, &uriparser_uri_parser, uri_str, base_url_object, is_constructor, is_constructor, NULL); } PHP_METHOD(Uri_Rfc3986_Uri, parse) @@ -480,7 +480,7 @@ static void create_whatwg_uri(INTERNAL_FUNCTION_PARAMETERS, bool is_constructor) Z_PARAM_ZVAL(errors) ZEND_PARSE_PARAMETERS_END(); - php_uri_instantiate_uri(INTERNAL_FUNCTION_PARAM_PASSTHRU, &lexbor_uri_handler, uri_str, base_url_object, is_constructor, is_constructor, errors); + php_uri_instantiate_uri(INTERNAL_FUNCTION_PARAM_PASSTHRU, &lexbor_uri_parser, uri_str, base_url_object, is_constructor, is_constructor, errors); } PHP_METHOD(Uri_WhatWg_Url, parse) @@ -618,14 +618,14 @@ static void uri_equals(INTERNAL_FUNCTION_PARAMETERS, zend_object *that_object, z exclude_fragment = zend_string_equals_literal(Z_STR_P(case_name), "ExcludeFragment"); } - zend_string *this_str = this_internal_uri->handler->uri_to_string( + zend_string *this_str = this_internal_uri->parser->uri_to_string( this_internal_uri->uri, URI_RECOMPOSITION_NORMALIZED_ASCII, exclude_fragment); if (this_str == NULL) { throw_cannot_recompose_uri_to_string(this_object); RETURN_THROWS(); } - zend_string *that_str = that_internal_uri->handler->uri_to_string( + zend_string *that_str = that_internal_uri->parser->uri_to_string( that_internal_uri->uri, URI_RECOMPOSITION_NORMALIZED_ASCII, exclude_fragment); if (that_str == NULL) { zend_string_release(this_str); @@ -661,7 +661,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, toRawString) uri_internal_t *internal_uri = uri_internal_from_obj(this_object); URI_ASSERT_INITIALIZATION(internal_uri); - zend_string *uri_str = internal_uri->handler->uri_to_string(internal_uri->uri, URI_RECOMPOSITION_RAW_ASCII, false); + zend_string *uri_str = internal_uri->parser->uri_to_string(internal_uri->uri, URI_RECOMPOSITION_RAW_ASCII, false); if (uri_str == NULL) { throw_cannot_recompose_uri_to_string(this_object); RETURN_THROWS(); @@ -678,7 +678,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, toString) uri_internal_t *internal_uri = uri_internal_from_obj(this_object); URI_ASSERT_INITIALIZATION(internal_uri); - zend_string *uri_str = internal_uri->handler->uri_to_string(internal_uri->uri, URI_RECOMPOSITION_NORMALIZED_ASCII, false); + zend_string *uri_str = internal_uri->parser->uri_to_string(internal_uri->uri, URI_RECOMPOSITION_NORMALIZED_ASCII, false); if (uri_str == NULL) { throw_cannot_recompose_uri_to_string(this_object); RETURN_THROWS(); @@ -699,7 +699,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, resolve) uri_internal_t *internal_uri = uri_internal_from_obj(this_object); URI_ASSERT_INITIALIZATION(internal_uri); - php_uri_instantiate_uri(INTERNAL_FUNCTION_PARAM_PASSTHRU, internal_uri->handler, uri_str, this_object, true, false, NULL); + php_uri_instantiate_uri(INTERNAL_FUNCTION_PARAM_PASSTHRU, internal_uri->parser, uri_str, this_object, true, false, NULL); } PHP_METHOD(Uri_Rfc3986_Uri, __serialize) @@ -711,7 +711,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, __serialize) URI_ASSERT_INITIALIZATION(internal_uri); /* Serialize state: "uri" key in the first array */ - zend_string *uri_str = internal_uri->handler->uri_to_string(internal_uri->uri, URI_RECOMPOSITION_RAW_ASCII, false); + zend_string *uri_str = internal_uri->parser->uri_to_string(internal_uri->uri, URI_RECOMPOSITION_RAW_ASCII, false); if (uri_str == NULL) { throw_cannot_recompose_uri_to_string(this_object); RETURN_THROWS(); @@ -732,7 +732,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, __serialize) zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &arr); } -static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS, const char *handler_name) +static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS, const char *uri_parser_name) { HashTable *data; @@ -768,11 +768,11 @@ static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS, const char *handler_na } uri_internal_t *internal_uri = uri_internal_from_obj(object); - internal_uri->handler = uri_handler_by_name(handler_name, strlen(handler_name)); + internal_uri->parser = uri_parser_by_name(uri_parser_name, strlen(uri_parser_name)); if (internal_uri->uri != NULL) { - internal_uri->handler->free_uri(internal_uri->uri); + internal_uri->parser->free_uri(internal_uri->uri); } - internal_uri->uri = internal_uri->handler->parse_uri(Z_STRVAL_P(uri_zv), Z_STRLEN_P(uri_zv), NULL, NULL, true); + internal_uri->uri = internal_uri->parser->parse_uri(Z_STRVAL_P(uri_zv), Z_STRLEN_P(uri_zv), NULL, NULL, true); if (internal_uri->uri == NULL) { zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %s object", ZSTR_VAL(object->ce->name)); RETURN_THROWS(); @@ -883,7 +883,7 @@ PHP_METHOD(Uri_WhatWg_Url, toUnicodeString) uri_internal_t *internal_uri = uri_internal_from_obj(this_object); URI_ASSERT_INITIALIZATION(internal_uri); - RETURN_STR(internal_uri->handler->uri_to_string(internal_uri->uri, URI_RECOMPOSITION_RAW_UNICODE, false)); + RETURN_STR(internal_uri->parser->uri_to_string(internal_uri->uri, URI_RECOMPOSITION_RAW_UNICODE, false)); } PHP_METHOD(Uri_WhatWg_Url, toAsciiString) @@ -894,7 +894,7 @@ PHP_METHOD(Uri_WhatWg_Url, toAsciiString) uri_internal_t *internal_uri = uri_internal_from_obj(this_object); URI_ASSERT_INITIALIZATION(internal_uri); - RETURN_STR(internal_uri->handler->uri_to_string(internal_uri->uri, URI_RECOMPOSITION_RAW_ASCII, false)); + RETURN_STR(internal_uri->parser->uri_to_string(internal_uri->uri, URI_RECOMPOSITION_RAW_ASCII, false)); } PHP_METHOD(Uri_WhatWg_Url, resolve) @@ -912,7 +912,7 @@ PHP_METHOD(Uri_WhatWg_Url, resolve) uri_internal_t *internal_uri = uri_internal_from_obj(this_object); URI_ASSERT_INITIALIZATION(internal_uri); - php_uri_instantiate_uri(INTERNAL_FUNCTION_PARAM_PASSTHRU, internal_uri->handler, uri_str, this_object, true, false, errors); + php_uri_instantiate_uri(INTERNAL_FUNCTION_PARAM_PASSTHRU, internal_uri->parser, uri_str, this_object, true, false, errors); } PHP_METHOD(Uri_WhatWg_Url, __serialize) @@ -924,7 +924,7 @@ PHP_METHOD(Uri_WhatWg_Url, __serialize) URI_ASSERT_INITIALIZATION(internal_uri); /* Serialize state: "uri" key in the first array */ - zend_string *uri_str = internal_uri->handler->uri_to_string(internal_uri->uri, URI_RECOMPOSITION_RAW_ASCII, false); + zend_string *uri_str = internal_uri->parser->uri_to_string(internal_uri->uri, URI_RECOMPOSITION_RAW_ASCII, false); if (uri_str == NULL) { throw_cannot_recompose_uri_to_string(this_object); RETURN_THROWS(); @@ -974,8 +974,8 @@ static void uri_free_obj_handler(zend_object *object) uri_object_t *uri_object = uri_object_from_obj(object); if (UNEXPECTED(uri_object->internal.uri != NULL)) { - uri_object->internal.handler->free_uri(uri_object->internal.uri); - uri_object->internal.handler = NULL; + uri_object->internal.parser->free_uri(uri_object->internal.uri); + uri_object->internal.parser = NULL; uri_object->internal.uri = NULL; } @@ -993,9 +993,9 @@ zend_object *uri_clone_obj_handler(zend_object *object) ZEND_ASSERT(new_object != NULL); uri_object_t *new_uri_object = uri_object_from_obj(new_object); - new_uri_object->internal.handler = internal_uri->handler; + new_uri_object->internal.parser = internal_uri->parser; - void *uri = internal_uri->handler->clone_uri(internal_uri->uri); + void *uri = internal_uri->parser->clone_uri(internal_uri->uri); ZEND_ASSERT(uri != NULL); new_uri_object->internal.uri = uri; @@ -1015,17 +1015,17 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_implementation_set_object_handlers(ze object_handlers->clone_obj = uri_clone_obj_handler; } -PHPAPI zend_result php_uri_handler_register(const uri_handler_t *uri_handler) +PHPAPI zend_result php_uri_parser_register(const uri_parser_t *uri_parser) { - zend_string *key = zend_string_init_interned(uri_handler->name, strlen(uri_handler->name), true); + zend_string *key = zend_string_init_interned(uri_parser->name, strlen(uri_parser->name), true); - ZEND_ASSERT(uri_handler->name != NULL); - ZEND_ASSERT(uri_handler->parse_uri != NULL); - ZEND_ASSERT(uri_handler->clone_uri != NULL || strcmp(uri_handler->name, URI_PARSER_PHP) == 0); - ZEND_ASSERT(uri_handler->uri_to_string != NULL || strcmp(uri_handler->name, URI_PARSER_PHP) == 0); - ZEND_ASSERT(uri_handler->free_uri != NULL); + ZEND_ASSERT(uri_parser->name != NULL); + ZEND_ASSERT(uri_parser->parse_uri != NULL); + ZEND_ASSERT(uri_parser->clone_uri != NULL || strcmp(uri_parser->name, URI_PARSER_PHP) == 0); + ZEND_ASSERT(uri_parser->uri_to_string != NULL || strcmp(uri_parser->name, URI_PARSER_PHP) == 0); + ZEND_ASSERT(uri_parser->free_uri != NULL); - zend_result result = zend_hash_add_ptr(&uri_handlers, key, (void *) uri_handler) != NULL ? SUCCESS : FAILURE; + zend_result result = zend_hash_add_ptr(&uri_parsers, key, (void *) uri_parser) != NULL ? SUCCESS : FAILURE; zend_string_release_ex(key, true); @@ -1047,13 +1047,13 @@ static PHP_MINIT_FUNCTION(uri) uri_whatwg_url_validation_error_ce = register_class_Uri_WhatWg_UrlValidationError(); uri_whatwg_url_validation_error_type_ce = register_class_Uri_WhatWg_UrlValidationErrorType(); - zend_hash_init(&uri_handlers, 4, NULL, NULL, true); + zend_hash_init(&uri_parsers, 4, NULL, NULL, true); - if (php_uri_handler_register(&uriparser_uri_handler) == FAILURE) { + if (php_uri_parser_register(&uriparser_uri_parser) == FAILURE) { return FAILURE; } - if (php_uri_handler_register(&lexbor_uri_handler) == FAILURE) { + if (php_uri_parser_register(&lexbor_uri_parser) == FAILURE) { return FAILURE; } @@ -1070,7 +1070,7 @@ static PHP_MINFO_FUNCTION(uri) static PHP_MSHUTDOWN_FUNCTION(uri) { - zend_hash_destroy(&uri_handlers); + zend_hash_destroy(&uri_parsers); return SUCCESS; } diff --git a/ext/uri/php_uri.h b/ext/uri/php_uri.h index b4ad18afb24a6..2b4394b60d49c 100644 --- a/ext/uri/php_uri.h +++ b/ext/uri/php_uri.h @@ -34,22 +34,22 @@ typedef struct php_uri { } php_uri; /** - * Registers a URI handler. The handler must have a unique name. + * Registers a URI parser. The parser must have a unique name. * - * @param uri_handler The URI handler + * @param uri_parser The URI parser * @return SUCCESS in case of success, FAILURE otherwise */ -PHPAPI zend_result php_uri_handler_register(const uri_handler_t *uri_handler); +PHPAPI zend_result php_uri_parser_register(const uri_parser_t *uri_parser); /** - * Returns the registered URI handler based on uri_handler_name. + * Returns the registered URI parser based on uri_parser_name. * - * @param uri_handler_name The URI handler name - * @return The URI handler + * @param uri_parser_name The URI parser name + * @return The URI parser */ -PHPAPI uri_handler_t *php_uri_get_handler(const zend_string *uri_handler_name); +PHPAPI uri_parser_t *php_uri_get_parser(const zend_string *uri_parser_name); -ZEND_ATTRIBUTE_NONNULL PHPAPI uri_internal_t *php_uri_parse(const uri_handler_t *uri_handler, const char *uri_str, size_t uri_str_len, bool silent); +ZEND_ATTRIBUTE_NONNULL PHPAPI uri_internal_t *php_uri_parse(const uri_parser_t *uri_parser, const char *uri_str, size_t uri_str_len, bool silent); /** * Retrieves the scheme component based on the read_mode and passes it to the zv ZVAL in case of success. @@ -186,7 +186,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_free(uri_internal_t *internal_uri); * - URI_COMPONENT_READ_NORMALIZED_ASCII: Retrieves the normalized variant of the requested URI component that must only contain ASCII characters * - URI_COMPONENT_READ_NORMALIZED_UNICODE: Retrieves the normalized variant of the requested URI component that may contain Unicode codepoints * - * @param uri_handler The URI handler whose parse_uri() handler is called + * @param uri_parser The URI parser whose parse_uri() handler is called * @param uri_str The input string that is going to be parsed * @param uri_str_len Length of the input string * @param read_mode The read mode based on which components are retrieved @@ -194,7 +194,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_free(uri_internal_t *internal_uri); * @return The created php_uri struct in case of success, NULL otherwise */ ZEND_ATTRIBUTE_NONNULL PHPAPI php_uri *php_uri_parse_to_struct( - const uri_handler_t *uri_handler, const char *uri_str, size_t uri_str_len, uri_component_read_mode_t read_mode, bool silent + const uri_parser_t *uri_parser, const char *uri_str, size_t uri_str_len, uri_component_read_mode_t read_mode, bool silent ); /** @@ -205,8 +205,8 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI php_uri *php_uri_parse_to_struct( ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_struct_free(php_uri *uri); ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2) PHPAPI void php_uri_instantiate_uri( - INTERNAL_FUNCTION_PARAMETERS, const uri_handler_t *handler, const zend_string *uri_str, const zend_object *base_url_object, - bool should_throw, bool should_update_this_object, zval *errors_zv + INTERNAL_FUNCTION_PARAMETERS, const uri_parser_t *uri_parser, const zend_string *uri_str, const zend_object *base_url_object, + bool should_throw, bool should_update_this_object, zval *errors_zv ); ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_implementation_set_object_handlers(zend_class_entry *ce, zend_object_handlers *object_handlers); diff --git a/ext/uri/php_uri_common.c b/ext/uri/php_uri_common.c index 29de370bd56b6..3edda609378f3 100644 --- a/ext/uri/php_uri_common.c +++ b/ext/uri/php_uri_common.c @@ -23,21 +23,21 @@ const uri_property_handler_t *uri_property_handler_from_internal_uri(const uri_i { switch (property_name) { case URI_PROPERTY_NAME_SCHEME: - return &internal_uri->handler->property_handlers.scheme; + return &internal_uri->parser->property_handlers.scheme; case URI_PROPERTY_NAME_USERNAME: - return &internal_uri->handler->property_handlers.username; + return &internal_uri->parser->property_handlers.username; case URI_PROPERTY_NAME_PASSWORD: - return &internal_uri->handler->property_handlers.password; + return &internal_uri->parser->property_handlers.password; case URI_PROPERTY_NAME_HOST: - return &internal_uri->handler->property_handlers.host; + return &internal_uri->parser->property_handlers.host; case URI_PROPERTY_NAME_PORT: - return &internal_uri->handler->property_handlers.port; + return &internal_uri->parser->property_handlers.port; case URI_PROPERTY_NAME_PATH: - return &internal_uri->handler->property_handlers.path; + return &internal_uri->parser->property_handlers.path; case URI_PROPERTY_NAME_QUERY: - return &internal_uri->handler->property_handlers.query; + return &internal_uri->parser->property_handlers.query; case URI_PROPERTY_NAME_FRAGMENT: - return &internal_uri->handler->property_handlers.fragment; + return &internal_uri->parser->property_handlers.fragment; EMPTY_SWITCH_DEFAULT_CASE() } } diff --git a/ext/uri/php_uri_common.h b/ext/uri/php_uri_common.h index 56b7dc9caa563..e18777a8673fc 100644 --- a/ext/uri/php_uri_common.h +++ b/ext/uri/php_uri_common.h @@ -75,9 +75,9 @@ typedef struct uri_property_handlers_t { uri_property_handler_t fragment; } uri_property_handlers_t; -typedef struct uri_handler_t { +typedef struct uri_parser_t { /** - * Name (the FQCN) of the URI handler. The "" name is reserved for the handler of the legacy parse_url(). + * Name (the FQCN) of the URI parser. The "" name is reserved for the handler of the legacy parse_url(). */ const char *name; @@ -139,10 +139,10 @@ typedef struct uri_handler_t { void (*free_uri)(void *uri); const uri_property_handlers_t property_handlers; -} uri_handler_t; +} uri_parser_t; typedef struct uri_internal_t { - const uri_handler_t *handler; + const uri_parser_t *parser; void *uri; } uri_internal_t; diff --git a/ext/uri/php_uriparser.c b/ext/uri/uri_parser_rfc3986.c similarity index 99% rename from ext/uri/php_uriparser.c rename to ext/uri/uri_parser_rfc3986.c index bd5789b664ce8..963eb210dfd4a 100644 --- a/ext/uri/php_uriparser.c +++ b/ext/uri/uri_parser_rfc3986.c @@ -15,7 +15,7 @@ */ #include "php.h" -#include "php_uriparser.h" +#include "uri_parser_rfc3986.h" #include "php_uri_common.h" #include "Zend/zend_smart_str.h" #include "Zend/zend_exceptions.h" @@ -401,7 +401,7 @@ ZEND_ATTRIBUTE_NONNULL static void uriparser_free_uri(void *uri) efree(uriparser_uris); } -const uri_handler_t uriparser_uri_handler = { +const uri_parser_t uriparser_uri_parser = { .name = URI_PARSER_RFC3986, .parse_uri = uriparser_parse_uri, .clone_uri = uriparser_clone_uri, diff --git a/ext/uri/php_uriparser.h b/ext/uri/uri_parser_rfc3986.h similarity index 96% rename from ext/uri/php_uriparser.h rename to ext/uri/uri_parser_rfc3986.h index 9d3ab5030a887..846b54340c531 100644 --- a/ext/uri/php_uriparser.h +++ b/ext/uri/uri_parser_rfc3986.h @@ -20,7 +20,7 @@ #include #include "php_uri_common.h" -extern const uri_handler_t uriparser_uri_handler; +extern const uri_parser_t uriparser_uri_parser; typedef struct uriparser_uris_t { UriUriA uri; diff --git a/ext/uri/php_lexbor.c b/ext/uri/uri_parser_whatwg.c similarity index 99% rename from ext/uri/php_lexbor.c rename to ext/uri/uri_parser_whatwg.c index b7ad297cd5b94..d21b71c273450 100644 --- a/ext/uri/php_lexbor.c +++ b/ext/uri/uri_parser_whatwg.c @@ -15,7 +15,7 @@ */ #include "php.h" -#include "php_lexbor.h" +#include "uri_parser_whatwg.h" #include "php_uri_common.h" #include "Zend/zend_enum.h" #include "Zend/zend_smart_str.h" @@ -619,7 +619,7 @@ static void lexbor_free_uri(void *uri) { } -const uri_handler_t lexbor_uri_handler = { +const uri_parser_t lexbor_uri_parser = { .name = URI_PARSER_WHATWG, .parse_uri = lexbor_parse_uri, .clone_uri = lexbor_clone_uri, diff --git a/ext/uri/php_lexbor.h b/ext/uri/uri_parser_whatwg.h similarity index 96% rename from ext/uri/php_lexbor.h rename to ext/uri/uri_parser_whatwg.h index 8420f7185094f..b0ef95112adf4 100644 --- a/ext/uri/php_lexbor.h +++ b/ext/uri/uri_parser_whatwg.h @@ -20,7 +20,7 @@ #include "php_uri_common.h" #include "lexbor/url/url.h" -extern const uri_handler_t lexbor_uri_handler; +extern const uri_parser_t lexbor_uri_parser; lxb_url_t *lexbor_parse_uri_ex(const char *uri_str, size_t uri_str_len, const lxb_url_t *lexbor_base_url, zval *errors, bool silent); diff --git a/main/streams/php_stream_context.h b/main/streams/php_stream_context.h index 59ec41b90b273..1890b32eaea24 100644 --- a/main/streams/php_stream_context.h +++ b/main/streams/php_stream_context.h @@ -66,9 +66,9 @@ PHPAPI void php_stream_context_set_option(php_stream_context *context, void php_stream_context_unset_option(php_stream_context *context, const char *wrappername, const char *optionname); -struct uri_handler_t; +struct uri_parser_t; -PHPAPI struct uri_handler_t *php_stream_context_get_uri_handler(const char *wrappername, php_stream_context *context); +PHPAPI struct uri_parser_t *php_stream_context_get_uri_parser(const char *wrappername, php_stream_context *context); PHPAPI php_stream_notifier *php_stream_notification_alloc(void); PHPAPI void php_stream_notification_free(php_stream_notifier *notifier); END_EXTERN_C() diff --git a/main/streams/streams.c b/main/streams/streams.c index 2107f4cd27b8b..fdebc19e28245 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -2458,22 +2458,22 @@ void php_stream_context_unset_option(php_stream_context *context, } /* }}} */ -PHPAPI struct uri_handler_t *php_stream_context_get_uri_handler(const char *wrappername, php_stream_context *context) +PHPAPI struct uri_parser_t *php_stream_context_get_uri_parser(const char *wrappername, php_stream_context *context) { if (context == NULL) { - return php_uri_get_handler(NULL); + return php_uri_get_parser(NULL); } - zval *uri_handler_name = php_stream_context_get_option(context, wrappername, "uri_parser_class"); - if (uri_handler_name == NULL || Z_TYPE_P(uri_handler_name) == IS_NULL) { - return php_uri_get_handler(NULL); + zval *uri_parser_name = php_stream_context_get_option(context, wrappername, "uri_parser_class"); + if (uri_parser_name == NULL || Z_TYPE_P(uri_parser_name) == IS_NULL) { + return php_uri_get_parser(NULL); } - if (Z_TYPE_P(uri_handler_name) != IS_STRING) { + if (Z_TYPE_P(uri_parser_name) != IS_STRING) { return NULL; } - return php_uri_get_handler(Z_STR_P(uri_handler_name)); + return php_uri_get_parser(Z_STR_P(uri_parser_name)); } /* {{{ php_stream_dirent_alphasort */