mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
uri: Clean up naming of remaining public symbols (#19917)
* uri: Rename `uri_object_t` to `php_uri_object` * uri: Rename `uri_(read|write)_component_*` to `php_uri_property_(read|write)_*_helper` * uri: Rename `URI_SERIALIZED_PROPERTY_NAME` to `PHP_URI_SERIALIZE_URI_FIELD_NAME` * uri: Rename `uri_internal_t` to `php_uri_internal` * uri: Use proper `php_uri_ce_` prefix for all CEs * uri: Make the object handlers `static` and remove them from the header
This commit is contained in:
@@ -2640,7 +2640,7 @@ static char *php_openssl_get_url_name(const char *resourcename,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uri_internal_t *internal_uri = php_uri_parse(uri_parser, resourcename, resourcenamelen, true);
|
||||
php_uri_internal *internal_uri = php_uri_parse(uri_parser, resourcename, resourcenamelen, true);
|
||||
if (internal_uri == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -32,17 +32,18 @@
|
||||
#include "php_uri_arginfo.h"
|
||||
#include "uriparser/UriBase.h"
|
||||
|
||||
zend_class_entry *uri_rfc3986_uri_ce;
|
||||
zend_object_handlers uri_rfc3986_uri_object_handlers;
|
||||
zend_class_entry *uri_whatwg_url_ce;
|
||||
zend_object_handlers uri_whatwg_uri_object_handlers;
|
||||
zend_class_entry *uri_comparison_mode_ce;
|
||||
zend_class_entry *uri_exception_ce;
|
||||
zend_class_entry *uri_error_ce;
|
||||
zend_class_entry *uri_invalid_uri_exception_ce;
|
||||
zend_class_entry *uri_whatwg_invalid_url_exception_ce;
|
||||
zend_class_entry *uri_whatwg_url_validation_error_type_ce;
|
||||
zend_class_entry *uri_whatwg_url_validation_error_ce;
|
||||
zend_class_entry *php_uri_ce_rfc3986_uri;
|
||||
zend_class_entry *php_uri_ce_whatwg_url;
|
||||
zend_class_entry *php_uri_ce_comparison_mode;
|
||||
zend_class_entry *php_uri_ce_exception;
|
||||
zend_class_entry *php_uri_ce_error;
|
||||
zend_class_entry *php_uri_ce_invalid_uri_exception;
|
||||
zend_class_entry *php_uri_ce_whatwg_invalid_url_exception;
|
||||
zend_class_entry *php_uri_ce_whatwg_url_validation_error_type;
|
||||
zend_class_entry *php_uri_ce_whatwg_url_validation_error;
|
||||
|
||||
static zend_object_handlers object_handlers_rfc3986_uri;
|
||||
static zend_object_handlers object_handlers_whatwg_uri;
|
||||
|
||||
static const zend_module_dep uri_deps[] = {
|
||||
ZEND_MOD_REQUIRED("lexbor")
|
||||
@@ -51,7 +52,7 @@ static const zend_module_dep uri_deps[] = {
|
||||
|
||||
static zend_array uri_parsers;
|
||||
|
||||
static HashTable *uri_get_debug_properties(uri_object_t *object)
|
||||
static HashTable *uri_get_debug_properties(php_uri_object *object)
|
||||
{
|
||||
const HashTable *std_properties = zend_std_get_properties(&object->std);
|
||||
HashTable *result = zend_array_dup(std_properties);
|
||||
@@ -108,9 +109,9 @@ PHPAPI const php_uri_parser *php_uri_get_parser(zend_string *uri_parser_name)
|
||||
return zend_hash_find_ptr(&uri_parsers, uri_parser_name);
|
||||
}
|
||||
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI uri_internal_t *php_uri_parse(const php_uri_parser *uri_parser, const char *uri_str, size_t uri_str_len, bool silent)
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI php_uri_internal *php_uri_parse(const php_uri_parser *uri_parser, const char *uri_str, size_t uri_str_len, bool silent)
|
||||
{
|
||||
uri_internal_t *internal_uri = emalloc(sizeof(*internal_uri));
|
||||
php_uri_internal *internal_uri = emalloc(sizeof(*internal_uri));
|
||||
internal_uri->parser = uri_parser;
|
||||
internal_uri->uri = uri_parser->parse(uri_str, uri_str_len, NULL, NULL, silent);
|
||||
|
||||
@@ -122,47 +123,47 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI uri_internal_t *php_uri_parse(const php_uri_parser
|
||||
return internal_uri;
|
||||
}
|
||||
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_scheme(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_scheme(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
{
|
||||
return internal_uri->parser->property_handler.scheme.read(internal_uri->uri, read_mode, zv);
|
||||
}
|
||||
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_username(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_username(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
{
|
||||
return internal_uri->parser->property_handler.username.read(internal_uri->uri, read_mode, zv);
|
||||
}
|
||||
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_password(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_password(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
{
|
||||
return internal_uri->parser->property_handler.password.read(internal_uri->uri, read_mode, zv);
|
||||
}
|
||||
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_host(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_host(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
{
|
||||
return internal_uri->parser->property_handler.host.read(internal_uri->uri, read_mode, zv);
|
||||
}
|
||||
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_port(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_port(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
{
|
||||
return internal_uri->parser->property_handler.port.read(internal_uri->uri, read_mode, zv);
|
||||
}
|
||||
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_path(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_path(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
{
|
||||
return internal_uri->parser->property_handler.path.read(internal_uri->uri, read_mode, zv);
|
||||
}
|
||||
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_query(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_query(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
{
|
||||
return internal_uri->parser->property_handler.query.read(internal_uri->uri, read_mode, zv);
|
||||
}
|
||||
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_fragment(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_fragment(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv)
|
||||
{
|
||||
return internal_uri->parser->property_handler.fragment.read(internal_uri->uri, read_mode, zv);
|
||||
}
|
||||
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_free(uri_internal_t *internal_uri)
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_free(php_uri_internal *internal_uri)
|
||||
{
|
||||
internal_uri->parser->destroy(internal_uri->uri);
|
||||
internal_uri->uri = NULL;
|
||||
@@ -173,7 +174,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_free(uri_internal_t *internal_uri)
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI php_uri *php_uri_parse_to_struct(
|
||||
const php_uri_parser *uri_parser, const char *uri_str, size_t uri_str_len, php_uri_component_read_mode read_mode, bool silent
|
||||
) {
|
||||
uri_internal_t *uri_internal = php_uri_parse(uri_parser, uri_str, uri_str_len, silent);
|
||||
php_uri_internal *uri_internal = php_uri_parse(uri_parser, uri_str, uri_str_len, silent);
|
||||
if (uri_internal == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -314,11 +315,11 @@ 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 zend_string *uri_str, const uri_object_t *base_url_object,
|
||||
INTERNAL_FUNCTION_PARAMETERS, const zend_string *uri_str, const php_uri_object *base_url_object,
|
||||
bool should_throw, bool should_update_this_object, zval *errors_zv
|
||||
) {
|
||||
|
||||
uri_object_t *uri_object;
|
||||
php_uri_object *uri_object;
|
||||
if (should_update_this_object) {
|
||||
uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
if (uri_object->uri != NULL) {
|
||||
@@ -377,11 +378,11 @@ static void create_rfc3986_uri(INTERNAL_FUNCTION_PARAMETERS, bool is_constructor
|
||||
ZEND_PARSE_PARAMETERS_START(1, 2)
|
||||
Z_PARAM_PATH_STR(uri_str)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_OBJ_OF_CLASS_OR_NULL(base_url_object, uri_rfc3986_uri_ce)
|
||||
Z_PARAM_OBJ_OF_CLASS_OR_NULL(base_url_object, php_uri_ce_rfc3986_uri)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
php_uri_instantiate_uri(INTERNAL_FUNCTION_PARAM_PASSTHRU,
|
||||
uri_str, base_url_object ? uri_object_from_obj(base_url_object) : NULL, is_constructor, is_constructor, NULL);
|
||||
uri_str, base_url_object ? php_uri_object_from_obj(base_url_object) : NULL, is_constructor, is_constructor, NULL);
|
||||
}
|
||||
|
||||
static bool is_list_of_whatwg_validation_errors(const HashTable *array)
|
||||
@@ -397,7 +398,7 @@ static bool is_list_of_whatwg_validation_errors(const HashTable *array)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!instanceof_function(Z_OBJCE_P(val), uri_whatwg_url_validation_error_ce)) {
|
||||
if (!instanceof_function(Z_OBJCE_P(val), php_uri_ce_whatwg_url_validation_error)) {
|
||||
return false;
|
||||
}
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
@@ -437,14 +438,14 @@ PHP_METHOD(Uri_WhatWg_InvalidUrlException, __construct)
|
||||
if (errors == NULL) {
|
||||
zval tmp;
|
||||
ZVAL_EMPTY_ARRAY(&tmp);
|
||||
zend_update_property(uri_whatwg_invalid_url_exception_ce, Z_OBJ_P(ZEND_THIS), ZEND_STRL("errors"), &tmp);
|
||||
zend_update_property(php_uri_ce_whatwg_invalid_url_exception, Z_OBJ_P(ZEND_THIS), ZEND_STRL("errors"), &tmp);
|
||||
} else {
|
||||
if (!is_list_of_whatwg_validation_errors(Z_ARR_P(errors))) {
|
||||
zend_argument_value_error(2, "must be a list of %s", ZSTR_VAL(uri_whatwg_url_validation_error_ce->name));
|
||||
zend_argument_value_error(2, "must be a list of %s", ZSTR_VAL(php_uri_ce_whatwg_url_validation_error->name));
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
zend_update_property(uri_whatwg_invalid_url_exception_ce, Z_OBJ_P(ZEND_THIS), ZEND_STRL("errors"), errors);
|
||||
zend_update_property(php_uri_ce_whatwg_invalid_url_exception, Z_OBJ_P(ZEND_THIS), ZEND_STRL("errors"), errors);
|
||||
}
|
||||
if (EG(exception)) {
|
||||
RETURN_THROWS();
|
||||
@@ -459,23 +460,23 @@ PHP_METHOD(Uri_WhatWg_UrlValidationError, __construct)
|
||||
|
||||
ZEND_PARSE_PARAMETERS_START(3, 3)
|
||||
Z_PARAM_STR(context)
|
||||
Z_PARAM_OBJECT_OF_CLASS(type, uri_whatwg_url_validation_error_type_ce)
|
||||
Z_PARAM_OBJECT_OF_CLASS(type, php_uri_ce_whatwg_url_validation_error_type)
|
||||
Z_PARAM_BOOL(failure)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
zend_update_property_str(uri_whatwg_url_validation_error_ce, Z_OBJ_P(ZEND_THIS), ZEND_STRL("context"), context);
|
||||
zend_update_property_str(php_uri_ce_whatwg_url_validation_error, Z_OBJ_P(ZEND_THIS), ZEND_STRL("context"), context);
|
||||
if (EG(exception)) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
zend_update_property_ex(uri_whatwg_url_validation_error_ce, Z_OBJ_P(ZEND_THIS), ZSTR_KNOWN(ZEND_STR_TYPE), type);
|
||||
zend_update_property_ex(php_uri_ce_whatwg_url_validation_error, Z_OBJ_P(ZEND_THIS), ZSTR_KNOWN(ZEND_STR_TYPE), type);
|
||||
if (EG(exception)) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
zval failure_zv;
|
||||
ZVAL_BOOL(&failure_zv, failure);
|
||||
zend_update_property(uri_whatwg_url_validation_error_ce, Z_OBJ_P(ZEND_THIS), ZEND_STRL("failure"), &failure_zv);
|
||||
zend_update_property(php_uri_ce_whatwg_url_validation_error, Z_OBJ_P(ZEND_THIS), ZEND_STRL("failure"), &failure_zv);
|
||||
if (EG(exception)) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
@@ -490,12 +491,12 @@ static void create_whatwg_uri(INTERNAL_FUNCTION_PARAMETERS, bool is_constructor)
|
||||
ZEND_PARSE_PARAMETERS_START(1, 3)
|
||||
Z_PARAM_PATH_STR(uri_str)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_OBJ_OF_CLASS_OR_NULL(base_url_object, uri_whatwg_url_ce)
|
||||
Z_PARAM_OBJ_OF_CLASS_OR_NULL(base_url_object, php_uri_ce_whatwg_url)
|
||||
Z_PARAM_ZVAL(errors)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
php_uri_instantiate_uri(INTERNAL_FUNCTION_PARAM_PASSTHRU,
|
||||
uri_str, base_url_object ? uri_object_from_obj(base_url_object) : NULL, is_constructor, is_constructor, errors);
|
||||
uri_str, base_url_object ? php_uri_object_from_obj(base_url_object) : NULL, is_constructor, is_constructor, errors);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_WhatWg_Url, parse)
|
||||
@@ -510,24 +511,24 @@ PHP_METHOD(Uri_WhatWg_Url, __construct)
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getScheme)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_SCHEME, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_SCHEME, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getRawScheme)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_SCHEME, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_SCHEME, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, withScheme)
|
||||
{
|
||||
uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_SCHEME);
|
||||
php_uri_property_write_str_or_null_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_SCHEME);
|
||||
}
|
||||
|
||||
static void rfc3986_userinfo_read(INTERNAL_FUNCTION_PARAMETERS, php_uri_component_read_mode read_mode)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
uri_object_t *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
php_uri_object *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
ZEND_ASSERT(uri_object->uri != NULL);
|
||||
|
||||
if (UNEXPECTED(php_uri_parser_rfc3986_userinfo_read(uri_object->uri, read_mode, return_value) == FAILURE)) {
|
||||
@@ -561,7 +562,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, withUserInfo)
|
||||
ZVAL_STR(&zv, value);
|
||||
}
|
||||
|
||||
uri_object_t *old_uri_object = uri_object_from_obj(Z_OBJ_P(ZEND_THIS));
|
||||
php_uri_object *old_uri_object = php_uri_object_from_obj(Z_OBJ_P(ZEND_THIS));
|
||||
ZEND_ASSERT(old_uri_object->uri != NULL);
|
||||
|
||||
zend_object *new_object = old_uri_object->std.handlers->clone_obj(&old_uri_object->std);
|
||||
@@ -573,7 +574,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, withUserInfo)
|
||||
* case of an exception being thrown. */
|
||||
RETVAL_OBJ(new_object);
|
||||
|
||||
uri_object_t *new_uri_object = uri_object_from_obj(new_object);
|
||||
php_uri_object *new_uri_object = php_uri_object_from_obj(new_object);
|
||||
ZEND_ASSERT(new_uri_object->uri != NULL);
|
||||
|
||||
if (UNEXPECTED(php_uri_parser_rfc3986_userinfo_write(new_uri_object->uri, &zv, NULL) == FAILURE)) {
|
||||
@@ -583,102 +584,102 @@ PHP_METHOD(Uri_Rfc3986_Uri, withUserInfo)
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getUsername)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_USERNAME, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_USERNAME, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getRawUsername)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_USERNAME, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_USERNAME, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getPassword)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PASSWORD, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PASSWORD, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getRawPassword)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PASSWORD, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PASSWORD, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getHost)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_HOST, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_HOST, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getRawHost)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_HOST, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_HOST, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, withHost)
|
||||
{
|
||||
uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_HOST);
|
||||
php_uri_property_write_str_or_null_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_HOST);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getPort)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PORT, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PORT, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, withPort)
|
||||
{
|
||||
uri_write_component_long_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PORT);
|
||||
php_uri_property_write_long_or_null_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PORT);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getPath)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PATH, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PATH, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getRawPath)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PATH, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PATH, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, withPath)
|
||||
{
|
||||
uri_write_component_str(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PATH);
|
||||
php_uri_property_write_str_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PATH);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getQuery)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_QUERY, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_QUERY, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getRawQuery)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_QUERY, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_QUERY, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, withQuery)
|
||||
{
|
||||
uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_QUERY);
|
||||
php_uri_property_write_str_or_null_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_QUERY);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getFragment)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_FRAGMENT, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_FRAGMENT, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, getRawFragment)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_FRAGMENT, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_FRAGMENT, PHP_URI_COMPONENT_READ_MODE_RAW);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, withFragment)
|
||||
{
|
||||
uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_FRAGMENT);
|
||||
php_uri_property_write_str_or_null_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_FRAGMENT);
|
||||
}
|
||||
|
||||
static void throw_cannot_recompose_uri_to_string(uri_object_t *object)
|
||||
static void throw_cannot_recompose_uri_to_string(php_uri_object *object)
|
||||
{
|
||||
zend_throw_exception_ex(uri_error_ce, 0, "Cannot recompose %s to a string", ZSTR_VAL(object->std.ce->name));
|
||||
zend_throw_exception_ex(php_uri_ce_error, 0, "Cannot recompose %s to a string", ZSTR_VAL(object->std.ce->name));
|
||||
}
|
||||
|
||||
static void uri_equals(INTERNAL_FUNCTION_PARAMETERS, uri_object_t *that_object, zend_object *comparison_mode)
|
||||
static void uri_equals(INTERNAL_FUNCTION_PARAMETERS, php_uri_object *that_object, zend_object *comparison_mode)
|
||||
{
|
||||
uri_object_t *this_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
php_uri_object *this_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
ZEND_ASSERT(this_object->uri != NULL);
|
||||
ZEND_ASSERT(that_object->uri != NULL);
|
||||
|
||||
@@ -722,19 +723,19 @@ PHP_METHOD(Uri_Rfc3986_Uri, equals)
|
||||
zend_object *comparison_mode = NULL;
|
||||
|
||||
ZEND_PARSE_PARAMETERS_START(1, 2)
|
||||
Z_PARAM_OBJ_OF_CLASS(that_object, uri_rfc3986_uri_ce)
|
||||
Z_PARAM_OBJ_OF_CLASS(that_object, php_uri_ce_rfc3986_uri)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_OBJ_OF_CLASS(comparison_mode, uri_comparison_mode_ce)
|
||||
Z_PARAM_OBJ_OF_CLASS(comparison_mode, php_uri_ce_comparison_mode)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
uri_equals(INTERNAL_FUNCTION_PARAM_PASSTHRU, uri_object_from_obj(that_object), comparison_mode);
|
||||
uri_equals(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_uri_object_from_obj(that_object), comparison_mode);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_Rfc3986_Uri, toRawString)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
uri_object_t *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
php_uri_object *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
ZEND_ASSERT(uri_object->uri != NULL);
|
||||
|
||||
zend_string *uri_str = uri_object->parser->to_string(uri_object->uri, PHP_URI_RECOMPOSITION_MODE_RAW_ASCII, false);
|
||||
@@ -750,7 +751,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, toString)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
uri_object_t *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
php_uri_object *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
ZEND_ASSERT(uri_object->uri != NULL);
|
||||
|
||||
zend_string *uri_str = uri_object->parser->to_string(uri_object->uri, PHP_URI_RECOMPOSITION_MODE_NORMALIZED_ASCII, false);
|
||||
@@ -778,7 +779,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, __serialize)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
uri_object_t *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
php_uri_object *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
ZEND_ASSERT(uri_object->uri != NULL);
|
||||
|
||||
/* Serialize state: "uri" key in the first array */
|
||||
@@ -794,7 +795,7 @@ PHP_METHOD(Uri_Rfc3986_Uri, __serialize)
|
||||
|
||||
zval arr;
|
||||
array_init(&arr);
|
||||
zend_hash_str_add_new(Z_ARRVAL(arr), URI_SERIALIZED_PROPERTY_NAME, sizeof(URI_SERIALIZED_PROPERTY_NAME) - 1, &tmp);
|
||||
zend_hash_str_add_new(Z_ARRVAL(arr), PHP_URI_SERIALIZE_URI_FIELD_NAME, sizeof(PHP_URI_SERIALIZE_URI_FIELD_NAME) - 1, &tmp);
|
||||
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &arr);
|
||||
|
||||
/* Serialize regular properties: second array */
|
||||
@@ -811,7 +812,7 @@ static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS)
|
||||
Z_PARAM_ARRAY_HT(data)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
uri_object_t *uri_object = uri_object_from_obj(Z_OBJ_P(ZEND_THIS));
|
||||
php_uri_object *uri_object = php_uri_object_from_obj(Z_OBJ_P(ZEND_THIS));
|
||||
if (uri_object->uri != NULL) {
|
||||
/* Intentionally throw two exceptions for proper chaining. */
|
||||
zend_throw_error(NULL, "Cannot modify readonly object of class %s", ZSTR_VAL(uri_object->std.ce->name));
|
||||
@@ -838,7 +839,7 @@ static void uri_unserialize(INTERNAL_FUNCTION_PARAMETERS)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
zval *uri_zv = zend_hash_str_find_ind(Z_ARRVAL_P(arr), ZEND_STRL(URI_SERIALIZED_PROPERTY_NAME));
|
||||
zval *uri_zv = zend_hash_str_find_ind(Z_ARRVAL_P(arr), ZEND_STRL(PHP_URI_SERIALIZE_URI_FIELD_NAME));
|
||||
if (uri_zv == NULL || Z_TYPE_P(uri_zv) != IS_STRING) {
|
||||
zend_throw_exception_ex(NULL, 0, "Invalid serialization data for %s object", ZSTR_VAL(uri_object->std.ce->name));
|
||||
RETURN_THROWS();
|
||||
@@ -873,44 +874,44 @@ PHP_METHOD(Uri_Rfc3986_Uri, __debugInfo)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
uri_object_t *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
php_uri_object *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
|
||||
RETURN_ARR(uri_get_debug_properties(uri_object));
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_WhatWg_Url, getScheme)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_SCHEME, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_SCHEME, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_WhatWg_Url, withScheme)
|
||||
{
|
||||
uri_write_component_str(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_SCHEME);
|
||||
php_uri_property_write_str_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_SCHEME);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_WhatWg_Url, withUsername)
|
||||
{
|
||||
uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_USERNAME);
|
||||
php_uri_property_write_str_or_null_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_USERNAME);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_WhatWg_Url, withPassword)
|
||||
{
|
||||
uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PASSWORD);
|
||||
php_uri_property_write_str_or_null_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_PASSWORD);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_WhatWg_Url, getAsciiHost)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_HOST, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_HOST, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_ASCII);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_WhatWg_Url, getUnicodeHost)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_HOST, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_UNICODE);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_HOST, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_UNICODE);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_WhatWg_Url, getFragment)
|
||||
{
|
||||
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_FRAGMENT, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_UNICODE);
|
||||
php_uri_property_read_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_URI_PROPERTY_NAME_FRAGMENT, PHP_URI_COMPONENT_READ_MODE_NORMALIZED_UNICODE);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_WhatWg_Url, equals)
|
||||
@@ -919,12 +920,12 @@ PHP_METHOD(Uri_WhatWg_Url, equals)
|
||||
zend_object *comparison_mode = NULL;
|
||||
|
||||
ZEND_PARSE_PARAMETERS_START(1, 2)
|
||||
Z_PARAM_OBJ_OF_CLASS(that_object, uri_whatwg_url_ce)
|
||||
Z_PARAM_OBJ_OF_CLASS(that_object, php_uri_ce_whatwg_url)
|
||||
Z_PARAM_OPTIONAL
|
||||
Z_PARAM_OBJ_OF_CLASS(comparison_mode, uri_comparison_mode_ce)
|
||||
Z_PARAM_OBJ_OF_CLASS(comparison_mode, php_uri_ce_comparison_mode)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
uri_equals(INTERNAL_FUNCTION_PARAM_PASSTHRU, uri_object_from_obj(that_object), comparison_mode);
|
||||
uri_equals(INTERNAL_FUNCTION_PARAM_PASSTHRU, php_uri_object_from_obj(that_object), comparison_mode);
|
||||
}
|
||||
|
||||
PHP_METHOD(Uri_WhatWg_Url, toUnicodeString)
|
||||
@@ -932,7 +933,7 @@ PHP_METHOD(Uri_WhatWg_Url, toUnicodeString)
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
zend_object *this_object = Z_OBJ_P(ZEND_THIS);
|
||||
uri_object_t *uri_object = uri_object_from_obj(this_object);
|
||||
php_uri_object *uri_object = php_uri_object_from_obj(this_object);
|
||||
ZEND_ASSERT(uri_object->uri != NULL);
|
||||
|
||||
RETURN_STR(uri_object->parser->to_string(uri_object->uri, PHP_URI_RECOMPOSITION_MODE_RAW_UNICODE, false));
|
||||
@@ -943,7 +944,7 @@ PHP_METHOD(Uri_WhatWg_Url, toAsciiString)
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
zend_object *this_object = Z_OBJ_P(ZEND_THIS);
|
||||
uri_object_t *uri_object = uri_object_from_obj(this_object);
|
||||
php_uri_object *uri_object = php_uri_object_from_obj(this_object);
|
||||
ZEND_ASSERT(uri_object->uri != NULL);
|
||||
|
||||
RETURN_STR(uri_object->parser->to_string(uri_object->uri, PHP_URI_RECOMPOSITION_MODE_RAW_ASCII, false));
|
||||
@@ -968,7 +969,7 @@ PHP_METHOD(Uri_WhatWg_Url, __serialize)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
uri_object_t *this_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
php_uri_object *this_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
ZEND_ASSERT(this_object->uri != NULL);
|
||||
|
||||
/* Serialize state: "uri" key in the first array */
|
||||
@@ -984,7 +985,7 @@ PHP_METHOD(Uri_WhatWg_Url, __serialize)
|
||||
|
||||
zval arr;
|
||||
array_init(&arr);
|
||||
zend_hash_str_add_new(Z_ARRVAL(arr), ZEND_STRL(URI_SERIALIZED_PROPERTY_NAME), &tmp);
|
||||
zend_hash_str_add_new(Z_ARRVAL(arr), ZEND_STRL(PHP_URI_SERIALIZE_URI_FIELD_NAME), &tmp);
|
||||
zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &arr);
|
||||
|
||||
/* Serialize regular properties: second array */
|
||||
@@ -1002,14 +1003,14 @@ PHP_METHOD(Uri_WhatWg_Url, __debugInfo)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
uri_object_t *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
php_uri_object *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
|
||||
RETURN_ARR(uri_get_debug_properties(uri_object));
|
||||
}
|
||||
|
||||
PHPAPI uri_object_t *php_uri_object_create(zend_class_entry *class_type, const php_uri_parser *parser)
|
||||
PHPAPI php_uri_object *php_uri_object_create(zend_class_entry *class_type, const php_uri_parser *parser)
|
||||
{
|
||||
uri_object_t *uri_object = zend_object_alloc(sizeof(*uri_object), class_type);
|
||||
php_uri_object *uri_object = zend_object_alloc(sizeof(*uri_object), class_type);
|
||||
|
||||
zend_object_std_init(&uri_object->std, class_type);
|
||||
object_properties_init(&uri_object->std, class_type);
|
||||
@@ -1032,7 +1033,7 @@ static zend_object *php_uri_object_create_whatwg(zend_class_entry *ce)
|
||||
|
||||
PHPAPI void php_uri_object_handler_free(zend_object *object)
|
||||
{
|
||||
uri_object_t *uri_object = uri_object_from_obj(object);
|
||||
php_uri_object *uri_object = php_uri_object_from_obj(object);
|
||||
|
||||
uri_object->parser->destroy(uri_object->uri);
|
||||
zend_object_std_dtor(&uri_object->std);
|
||||
@@ -1040,11 +1041,11 @@ PHPAPI void php_uri_object_handler_free(zend_object *object)
|
||||
|
||||
PHPAPI zend_object *php_uri_object_handler_clone(zend_object *object)
|
||||
{
|
||||
uri_object_t *uri_object = uri_object_from_obj(object);
|
||||
php_uri_object *uri_object = php_uri_object_from_obj(object);
|
||||
|
||||
ZEND_ASSERT(uri_object->uri != NULL);
|
||||
|
||||
uri_object_t *new_uri_object = uri_object_from_obj(object->ce->create_object(object->ce));
|
||||
php_uri_object *new_uri_object = php_uri_object_from_obj(object->ce->create_object(object->ce));
|
||||
ZEND_ASSERT(new_uri_object->parser == uri_object->parser);
|
||||
|
||||
void *uri = uri_object->parser->clone(uri_object->uri);
|
||||
@@ -1076,29 +1077,29 @@ PHPAPI zend_result php_uri_parser_register(const php_uri_parser *uri_parser)
|
||||
|
||||
static PHP_MINIT_FUNCTION(uri)
|
||||
{
|
||||
uri_rfc3986_uri_ce = register_class_Uri_Rfc3986_Uri();
|
||||
uri_rfc3986_uri_ce->create_object = php_uri_object_create_rfc3986;
|
||||
uri_rfc3986_uri_ce->default_object_handlers = &uri_rfc3986_uri_object_handlers;
|
||||
memcpy(&uri_rfc3986_uri_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
uri_rfc3986_uri_object_handlers.offset = XtOffsetOf(uri_object_t, std);
|
||||
uri_rfc3986_uri_object_handlers.free_obj = php_uri_object_handler_free;
|
||||
uri_rfc3986_uri_object_handlers.clone_obj = php_uri_object_handler_clone;
|
||||
php_uri_ce_rfc3986_uri = register_class_Uri_Rfc3986_Uri();
|
||||
php_uri_ce_rfc3986_uri->create_object = php_uri_object_create_rfc3986;
|
||||
php_uri_ce_rfc3986_uri->default_object_handlers = &object_handlers_rfc3986_uri;
|
||||
memcpy(&object_handlers_rfc3986_uri, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
object_handlers_rfc3986_uri.offset = XtOffsetOf(php_uri_object, std);
|
||||
object_handlers_rfc3986_uri.free_obj = php_uri_object_handler_free;
|
||||
object_handlers_rfc3986_uri.clone_obj = php_uri_object_handler_clone;
|
||||
|
||||
uri_whatwg_url_ce = register_class_Uri_WhatWg_Url();
|
||||
uri_whatwg_url_ce->create_object = php_uri_object_create_whatwg;
|
||||
uri_whatwg_url_ce->default_object_handlers = &uri_whatwg_uri_object_handlers;
|
||||
memcpy(&uri_whatwg_uri_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
uri_whatwg_uri_object_handlers.offset = XtOffsetOf(uri_object_t, std);
|
||||
uri_whatwg_uri_object_handlers.free_obj = php_uri_object_handler_free;
|
||||
uri_whatwg_uri_object_handlers.clone_obj = php_uri_object_handler_clone;
|
||||
php_uri_ce_whatwg_url = register_class_Uri_WhatWg_Url();
|
||||
php_uri_ce_whatwg_url->create_object = php_uri_object_create_whatwg;
|
||||
php_uri_ce_whatwg_url->default_object_handlers = &object_handlers_whatwg_uri;
|
||||
memcpy(&object_handlers_whatwg_uri, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
object_handlers_whatwg_uri.offset = XtOffsetOf(php_uri_object, std);
|
||||
object_handlers_whatwg_uri.free_obj = php_uri_object_handler_free;
|
||||
object_handlers_whatwg_uri.clone_obj = php_uri_object_handler_clone;
|
||||
|
||||
uri_comparison_mode_ce = register_class_Uri_UriComparisonMode();
|
||||
uri_exception_ce = register_class_Uri_UriException(zend_ce_exception);
|
||||
uri_error_ce = register_class_Uri_UriError(zend_ce_error);
|
||||
uri_invalid_uri_exception_ce = register_class_Uri_InvalidUriException(uri_exception_ce);
|
||||
uri_whatwg_invalid_url_exception_ce = register_class_Uri_WhatWg_InvalidUrlException(uri_invalid_uri_exception_ce);
|
||||
uri_whatwg_url_validation_error_ce = register_class_Uri_WhatWg_UrlValidationError();
|
||||
uri_whatwg_url_validation_error_type_ce = register_class_Uri_WhatWg_UrlValidationErrorType();
|
||||
php_uri_ce_comparison_mode = register_class_Uri_UriComparisonMode();
|
||||
php_uri_ce_exception = register_class_Uri_UriException(zend_ce_exception);
|
||||
php_uri_ce_error = register_class_Uri_UriError(zend_ce_error);
|
||||
php_uri_ce_invalid_uri_exception = register_class_Uri_InvalidUriException(php_uri_ce_exception);
|
||||
php_uri_ce_whatwg_invalid_url_exception = register_class_Uri_WhatWg_InvalidUrlException(php_uri_ce_invalid_uri_exception);
|
||||
php_uri_ce_whatwg_url_validation_error = register_class_Uri_WhatWg_UrlValidationError();
|
||||
php_uri_ce_whatwg_url_validation_error_type = register_class_Uri_WhatWg_UrlValidationErrorType();
|
||||
|
||||
zend_hash_init(&uri_parsers, 4, NULL, NULL, true);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ PHPAPI zend_result php_uri_parser_register(const php_uri_parser *uri_parser);
|
||||
*/
|
||||
PHPAPI const php_uri_parser *php_uri_get_parser(zend_string *uri_parser_name);
|
||||
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI uri_internal_t *php_uri_parse(const php_uri_parser *uri_parser, const char *uri_str, size_t uri_str_len, bool silent);
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI php_uri_internal *php_uri_parse(const php_uri_parser *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.
|
||||
@@ -66,7 +66,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI uri_internal_t *php_uri_parse(const php_uri_parser
|
||||
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
|
||||
* @return SUCCESS in case of success, FAILURE otherwise.
|
||||
*/
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_scheme(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_scheme(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
|
||||
/**
|
||||
* Retrieves the username component based on the read_mode and passes it to the zv ZVAL in case of success.
|
||||
@@ -81,7 +81,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_scheme(const uri_internal_
|
||||
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
|
||||
* @return SUCCESS in case of success, FAILURE otherwise.
|
||||
*/
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_username(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_username(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
|
||||
/**
|
||||
* Retrieves the password component based on the read_mode and passes it to the zv ZVAL in case of success.
|
||||
@@ -96,7 +96,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_username(const uri_interna
|
||||
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
|
||||
* @return SUCCESS in case of success, FAILURE otherwise.
|
||||
*/
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_password(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_password(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
|
||||
/**
|
||||
* Retrieves the host component based on the read_mode and passes it to the zv ZVAL in case of success.
|
||||
@@ -111,7 +111,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_password(const uri_interna
|
||||
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
|
||||
* @return SUCCESS in case of success, FAILURE otherwise.
|
||||
*/
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_host(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_host(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
|
||||
/**
|
||||
* Retrieves the port component based on the read_mode and passes it to the zv ZVAL in case of success.
|
||||
@@ -126,7 +126,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_host(const uri_internal_t
|
||||
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_LONG or IS_NULL).
|
||||
* @return SUCCESS in case of success, FAILURE otherwise.
|
||||
*/
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_port(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_port(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
|
||||
/**
|
||||
* Retrieves the path component based on the read_mode and passes it to the zv ZVAL in case of success.
|
||||
@@ -141,7 +141,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_port(const uri_internal_t
|
||||
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
|
||||
* @return SUCCESS in case of success, FAILURE otherwise.
|
||||
*/
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_path(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_path(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
|
||||
/**
|
||||
* Retrieves the query component based on the read_mode and passes it to the zv ZVAL in case of success.
|
||||
@@ -156,7 +156,7 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_path(const uri_internal_t
|
||||
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
|
||||
* @return SUCCESS in case of success, FAILURE otherwise.
|
||||
*/
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_query(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_query(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
|
||||
/**
|
||||
* Retrieves the fragment component based on the read_mode and passes it to the zv ZVAL in case of success.
|
||||
@@ -171,14 +171,14 @@ ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_query(const uri_internal_t
|
||||
* @param zv The output parameter containing the retrieved component as a ZVAL (either IS_STRING or IS_NULL).
|
||||
* @return SUCCESS in case of success, FAILURE otherwise.
|
||||
*/
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_fragment(const uri_internal_t *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI zend_result php_uri_get_fragment(const php_uri_internal *internal_uri, php_uri_component_read_mode read_mode, zval *zv);
|
||||
|
||||
/**
|
||||
* Frees the uri member within the provided internal URI.
|
||||
*
|
||||
* @param internal_uri The internal URI
|
||||
*/
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_free(uri_internal_t *internal_uri);
|
||||
ZEND_ATTRIBUTE_NONNULL PHPAPI void php_uri_free(php_uri_internal *internal_uri);
|
||||
|
||||
/**
|
||||
* Creates a new php_uri struct containing all the URI components. The components are retrieved based on the read_mode parameter.
|
||||
@@ -207,7 +207,7 @@ 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 zend_string *uri_str, const uri_object_t *base_url_object,
|
||||
INTERNAL_FUNCTION_PARAMETERS, const zend_string *uri_str, const php_uri_object *base_url_object,
|
||||
bool should_throw, bool should_update_this_object, zval *errors_zv
|
||||
);
|
||||
|
||||
|
||||
@@ -42,24 +42,24 @@ static zend_string *get_known_string_by_property_name(php_uri_property_name prop
|
||||
}
|
||||
}
|
||||
|
||||
void uri_read_component(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, php_uri_component_read_mode component_read_mode)
|
||||
void php_uri_property_read_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, php_uri_component_read_mode component_read_mode)
|
||||
{
|
||||
ZEND_PARSE_PARAMETERS_NONE();
|
||||
|
||||
uri_object_t *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
php_uri_object *uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
ZEND_ASSERT(uri_object->uri != NULL);
|
||||
|
||||
const php_uri_property_handler *property_handler = php_uri_parser_property_handler_by_name(uri_object->parser, property_name);
|
||||
|
||||
if (UNEXPECTED(property_handler->read(uri_object->uri, component_read_mode, return_value) == FAILURE)) {
|
||||
zend_throw_exception_ex(uri_error_ce, 0, "The %s component cannot be retrieved", ZSTR_VAL(get_known_string_by_property_name(property_name)));
|
||||
zend_throw_exception_ex(php_uri_ce_error, 0, "The %s component cannot be retrieved", ZSTR_VAL(get_known_string_by_property_name(property_name)));
|
||||
RETURN_THROWS();
|
||||
}
|
||||
}
|
||||
|
||||
static void uri_write_component_ex(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, zval *property_zv)
|
||||
static void php_uri_property_write_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, zval *property_zv)
|
||||
{
|
||||
uri_object_t *old_uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
php_uri_object *old_uri_object = Z_URI_OBJECT_P(ZEND_THIS);
|
||||
ZEND_ASSERT(old_uri_object->uri != NULL);
|
||||
|
||||
zend_object *new_object = old_uri_object->std.handlers->clone_obj(&old_uri_object->std);
|
||||
@@ -73,7 +73,7 @@ static void uri_write_component_ex(INTERNAL_FUNCTION_PARAMETERS, php_uri_propert
|
||||
|
||||
const php_uri_property_handler *property_handler = php_uri_parser_property_handler_by_name(old_uri_object->parser, property_name);
|
||||
|
||||
uri_object_t *new_uri_object = uri_object_from_obj(new_object);
|
||||
php_uri_object *new_uri_object = php_uri_object_from_obj(new_object);
|
||||
ZEND_ASSERT(new_uri_object->uri != NULL);
|
||||
if (UNEXPECTED(property_handler->write == NULL)) {
|
||||
zend_readonly_property_modification_error_ex(ZSTR_VAL(old_uri_object->std.ce->name),
|
||||
@@ -91,7 +91,7 @@ static void uri_write_component_ex(INTERNAL_FUNCTION_PARAMETERS, php_uri_propert
|
||||
ZEND_ASSERT(Z_ISUNDEF(errors));
|
||||
}
|
||||
|
||||
void uri_write_component_str(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name)
|
||||
void php_uri_property_write_str_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name)
|
||||
{
|
||||
zend_string *value;
|
||||
|
||||
@@ -102,10 +102,10 @@ void uri_write_component_str(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name
|
||||
zval zv;
|
||||
ZVAL_STR(&zv, value);
|
||||
|
||||
uri_write_component_ex(INTERNAL_FUNCTION_PARAM_PASSTHRU, property_name, &zv);
|
||||
php_uri_property_write_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, property_name, &zv);
|
||||
}
|
||||
|
||||
void uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name)
|
||||
void php_uri_property_write_str_or_null_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name)
|
||||
{
|
||||
zend_string *value;
|
||||
|
||||
@@ -120,10 +120,10 @@ void uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAMETERS, php_uri_prope
|
||||
ZVAL_STR(&zv, value);
|
||||
}
|
||||
|
||||
uri_write_component_ex(INTERNAL_FUNCTION_PARAM_PASSTHRU, property_name, &zv);
|
||||
php_uri_property_write_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, property_name, &zv);
|
||||
}
|
||||
|
||||
void uri_write_component_long_or_null(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name)
|
||||
void php_uri_property_write_long_or_null_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name)
|
||||
{
|
||||
zend_long value;
|
||||
bool value_is_null;
|
||||
@@ -139,5 +139,5 @@ void uri_write_component_long_or_null(INTERNAL_FUNCTION_PARAMETERS, php_uri_prop
|
||||
ZVAL_LONG(&zv, value);
|
||||
}
|
||||
|
||||
uri_write_component_ex(INTERNAL_FUNCTION_PARAM_PASSTHRU, property_name, &zv);
|
||||
php_uri_property_write_helper(INTERNAL_FUNCTION_PARAM_PASSTHRU, property_name, &zv);
|
||||
}
|
||||
|
||||
@@ -17,17 +17,15 @@
|
||||
#ifndef PHP_URI_COMMON_H
|
||||
#define PHP_URI_COMMON_H
|
||||
|
||||
extern zend_class_entry *uri_rfc3986_uri_ce;
|
||||
extern zend_object_handlers uri_rfc3986_uri_object_handlers;
|
||||
extern zend_class_entry *uri_whatwg_url_ce;
|
||||
extern zend_object_handlers uri_whatwg_uri_object_handlers;
|
||||
extern zend_class_entry *uri_comparison_mode_ce;
|
||||
extern zend_class_entry *uri_exception_ce;
|
||||
extern zend_class_entry *uri_error_ce;
|
||||
extern zend_class_entry *uri_invalid_uri_exception_ce;
|
||||
extern zend_class_entry *uri_whatwg_invalid_url_exception_ce;
|
||||
extern zend_class_entry *uri_whatwg_url_validation_error_type_ce;
|
||||
extern zend_class_entry *uri_whatwg_url_validation_error_ce;
|
||||
extern zend_class_entry *php_uri_ce_rfc3986_uri;
|
||||
extern zend_class_entry *php_uri_ce_whatwg_url;
|
||||
extern zend_class_entry *php_uri_ce_comparison_mode;
|
||||
extern zend_class_entry *php_uri_ce_exception;
|
||||
extern zend_class_entry *php_uri_ce_error;
|
||||
extern zend_class_entry *php_uri_ce_invalid_uri_exception;
|
||||
extern zend_class_entry *php_uri_ce_whatwg_invalid_url_exception;
|
||||
extern zend_class_entry *php_uri_ce_whatwg_url_validation_error_type;
|
||||
extern zend_class_entry *php_uri_ce_whatwg_url_validation_error;
|
||||
|
||||
typedef enum php_uri_recomposition_mode {
|
||||
PHP_URI_RECOMPOSITION_MODE_RAW_ASCII,
|
||||
@@ -137,31 +135,31 @@ typedef struct php_uri_parser {
|
||||
} property_handler;
|
||||
} php_uri_parser;
|
||||
|
||||
typedef struct uri_internal_t {
|
||||
typedef struct php_uri_internal {
|
||||
const php_uri_parser *parser;
|
||||
void *uri;
|
||||
} uri_internal_t;
|
||||
} php_uri_internal;
|
||||
|
||||
typedef struct uri_object_t {
|
||||
typedef struct php_uri_object {
|
||||
const php_uri_parser *parser;
|
||||
void *uri;
|
||||
zend_object std;
|
||||
} uri_object_t;
|
||||
} php_uri_object;
|
||||
|
||||
static inline uri_object_t *uri_object_from_obj(zend_object *object) {
|
||||
return (uri_object_t*)((char*)(object) - XtOffsetOf(uri_object_t, std));
|
||||
static inline php_uri_object *php_uri_object_from_obj(zend_object *object) {
|
||||
return (php_uri_object*)((char*)(object) - XtOffsetOf(php_uri_object, std));
|
||||
}
|
||||
|
||||
#define Z_URI_OBJECT_P(zv) uri_object_from_obj(Z_OBJ_P((zv)))
|
||||
#define Z_URI_OBJECT_P(zv) php_uri_object_from_obj(Z_OBJ_P((zv)))
|
||||
|
||||
PHPAPI uri_object_t *php_uri_object_create(zend_class_entry *class_type, const php_uri_parser *parser);
|
||||
PHPAPI php_uri_object *php_uri_object_create(zend_class_entry *class_type, const php_uri_parser *parser);
|
||||
PHPAPI void php_uri_object_handler_free(zend_object *object);
|
||||
PHPAPI zend_object *php_uri_object_handler_clone(zend_object *object);
|
||||
|
||||
#define PHP_URI_PARSER_RFC3986 "Uri\\Rfc3986\\Uri"
|
||||
#define PHP_URI_PARSER_WHATWG "Uri\\WhatWg\\Url"
|
||||
#define PHP_URI_PARSER_PHP_PARSE_URL "parse_url"
|
||||
#define URI_SERIALIZED_PROPERTY_NAME "uri"
|
||||
#define PHP_URI_SERIALIZE_URI_FIELD_NAME "uri"
|
||||
|
||||
static inline const php_uri_property_handler *php_uri_parser_property_handler_by_name(const php_uri_parser *parser, php_uri_property_name property_name)
|
||||
{
|
||||
@@ -186,9 +184,9 @@ static inline const php_uri_property_handler *php_uri_parser_property_handler_by
|
||||
}
|
||||
}
|
||||
|
||||
void uri_read_component(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, php_uri_component_read_mode component_read_mode);
|
||||
void uri_write_component_str(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name);
|
||||
void uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name);
|
||||
void uri_write_component_long_or_null(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name);
|
||||
void php_uri_property_read_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name, php_uri_component_read_mode component_read_mode);
|
||||
void php_uri_property_write_str_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name);
|
||||
void php_uri_property_write_str_or_null_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name);
|
||||
void php_uri_property_write_long_or_null_helper(INTERNAL_FUNCTION_PARAMETERS, php_uri_property_name property_name);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -148,7 +148,7 @@ static void *uri_parser_php_parse_url_parse(const char *uri_str, size_t uri_str_
|
||||
|
||||
php_url *url = php_url_parse_ex2(uri_str, uri_str_len, &has_port);
|
||||
if (url == NULL && !silent) {
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "The specified URI is malformed", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "The specified URI is malformed", 0);
|
||||
}
|
||||
|
||||
return url;
|
||||
|
||||
@@ -132,11 +132,11 @@ static zend_result php_uri_parser_rfc3986_scheme_write(void *uri, zval *value, z
|
||||
case URI_SUCCESS:
|
||||
return SUCCESS;
|
||||
case URI_ERROR_SYNTAX:
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "The specified scheme is malformed", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "The specified scheme is malformed", 0);
|
||||
return FAILURE;
|
||||
default:
|
||||
/* This should be unreachable in practice. */
|
||||
zend_throw_exception(uri_error_ce, "Failed to update the scheme", 0);
|
||||
zend_throw_exception(php_uri_ce_error, "Failed to update the scheme", 0);
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -169,14 +169,14 @@ zend_result php_uri_parser_rfc3986_userinfo_write(void *uri, zval *value, zval *
|
||||
case URI_SUCCESS:
|
||||
return SUCCESS;
|
||||
case URI_ERROR_SETUSERINFO_HOST_NOT_SET:
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "Cannot set a userinfo without having a host", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "Cannot set a userinfo without having a host", 0);
|
||||
return FAILURE;
|
||||
case URI_ERROR_SYNTAX:
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "The specified userinfo is malformed", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "The specified userinfo is malformed", 0);
|
||||
return FAILURE;
|
||||
default:
|
||||
/* This should be unreachable in practice. */
|
||||
zend_throw_exception(uri_error_ce, "Failed to update the userinfo", 0);
|
||||
zend_throw_exception(php_uri_ce_error, "Failed to update the userinfo", 0);
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -261,17 +261,17 @@ static zend_result php_uri_parser_rfc3986_host_write(void *uri, zval *value, zva
|
||||
case URI_SUCCESS:
|
||||
return SUCCESS;
|
||||
case URI_ERROR_SETHOST_PORT_SET:
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "Cannot remove the host from a URI that has a port", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "Cannot remove the host from a URI that has a port", 0);
|
||||
return FAILURE;
|
||||
case URI_ERROR_SETHOST_USERINFO_SET:
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "Cannot remove the host from a URI that has a userinfo", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "Cannot remove the host from a URI that has a userinfo", 0);
|
||||
return FAILURE;
|
||||
case URI_ERROR_SYNTAX:
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "The specified host is malformed", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "The specified host is malformed", 0);
|
||||
return FAILURE;
|
||||
default:
|
||||
/* This should be unreachable in practice. */
|
||||
zend_throw_exception(uri_error_ce, "Failed to update the host", 0);
|
||||
zend_throw_exception(php_uri_ce_error, "Failed to update the host", 0);
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -324,14 +324,14 @@ static zend_result php_uri_parser_rfc3986_port_write(void *uri, zval *value, zva
|
||||
case URI_SUCCESS:
|
||||
return SUCCESS;
|
||||
case URI_ERROR_SETPORT_HOST_NOT_SET:
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "Cannot set a port without having a host", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "Cannot set a port without having a host", 0);
|
||||
return FAILURE;
|
||||
case URI_ERROR_SYNTAX:
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "The specified port is malformed", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "The specified port is malformed", 0);
|
||||
return FAILURE;
|
||||
default:
|
||||
/* This should be unreachable in practice. */
|
||||
zend_throw_exception(uri_error_ce, "Failed to update the port", 0);
|
||||
zend_throw_exception(php_uri_ce_error, "Failed to update the port", 0);
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -379,11 +379,11 @@ static zend_result php_uri_parser_rfc3986_path_write(void *uri, zval *value, zva
|
||||
case URI_SUCCESS:
|
||||
return SUCCESS;
|
||||
case URI_ERROR_SYNTAX:
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "The specified path is malformed", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "The specified path is malformed", 0);
|
||||
return FAILURE;
|
||||
default:
|
||||
/* This should be unreachable in practice. */
|
||||
zend_throw_exception(uri_error_ce, "Failed to update the path", 0);
|
||||
zend_throw_exception(php_uri_ce_error, "Failed to update the path", 0);
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -416,11 +416,11 @@ static zend_result php_uri_parser_rfc3986_query_write(void *uri, zval *value, zv
|
||||
case URI_SUCCESS:
|
||||
return SUCCESS;
|
||||
case URI_ERROR_SYNTAX:
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "The specified query is malformed", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "The specified query is malformed", 0);
|
||||
return FAILURE;
|
||||
default:
|
||||
/* This should be unreachable in practice. */
|
||||
zend_throw_exception(uri_error_ce, "Failed to update the query", 0);
|
||||
zend_throw_exception(php_uri_ce_error, "Failed to update the query", 0);
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -453,11 +453,11 @@ static zend_result php_uri_parser_rfc3986_fragment_write(void *uri, zval *value,
|
||||
case URI_SUCCESS:
|
||||
return SUCCESS;
|
||||
case URI_ERROR_SYNTAX:
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "The specified fragment is malformed", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "The specified fragment is malformed", 0);
|
||||
return FAILURE;
|
||||
default:
|
||||
/* This should be unreachable in practice. */
|
||||
zend_throw_exception(uri_error_ce, "Failed to update the fragment", 0);
|
||||
zend_throw_exception(php_uri_ce_error, "Failed to update the fragment", 0);
|
||||
return FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -480,11 +480,11 @@ php_uri_parser_rfc3986_uris *php_uri_parser_rfc3986_parse_ex(const char *uri_str
|
||||
if (!silent) {
|
||||
switch (result) {
|
||||
case URI_ERROR_SYNTAX:
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "The specified URI is malformed", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "The specified URI is malformed", 0);
|
||||
break;
|
||||
default:
|
||||
/* This should be unreachable in practice. */
|
||||
zend_throw_exception(uri_error_ce, "Failed to parse the specified URI", 0);
|
||||
zend_throw_exception(php_uri_ce_error, "Failed to parse the specified URI", 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -502,11 +502,11 @@ php_uri_parser_rfc3986_uris *php_uri_parser_rfc3986_parse_ex(const char *uri_str
|
||||
if (!silent) {
|
||||
switch (result) {
|
||||
case URI_ERROR_ADDBASE_REL_BASE:
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "The specified base URI must be absolute", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "The specified base URI must be absolute", 0);
|
||||
break;
|
||||
default:
|
||||
/* This should be unreachable in practice. */
|
||||
zend_throw_exception(uri_error_ce, "Failed to resolve the specified URI against the base URI", 0);
|
||||
zend_throw_exception(php_uri_ce_error, "Failed to resolve the specified URI against the base URI", 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -525,7 +525,7 @@ php_uri_parser_rfc3986_uris *php_uri_parser_rfc3986_parse_ex(const char *uri_str
|
||||
if (has_text_range(&uri.portText) && get_text_range_length(&uri.portText) > 0) {
|
||||
if (port_str_to_zend_long_checked(uri.portText.first, get_text_range_length(&uri.portText)) == -1) {
|
||||
if (!silent) {
|
||||
zend_throw_exception(uri_invalid_uri_exception_ce, "The port is out of range", 0);
|
||||
zend_throw_exception(php_uri_ce_invalid_uri_exception, "The port is out of range", 0);
|
||||
}
|
||||
|
||||
goto fail;
|
||||
|
||||
@@ -73,8 +73,8 @@ static const char *fill_errors(zval *errors)
|
||||
lexbor_plog_entry_t *lxb_error;
|
||||
while ((lxb_error = lexbor_array_obj_pop(&lexbor_parser.log->list)) != NULL) {
|
||||
zval error;
|
||||
object_init_ex(&error, uri_whatwg_url_validation_error_ce);
|
||||
zend_update_property_string(uri_whatwg_url_validation_error_ce, Z_OBJ(error), ZEND_STRL("context"), (const char *) lxb_error->data);
|
||||
object_init_ex(&error, php_uri_ce_whatwg_url_validation_error);
|
||||
zend_update_property_string(php_uri_ce_whatwg_url_validation_error, Z_OBJ(error), ZEND_STRL("context"), (const char *) lxb_error->data);
|
||||
|
||||
const char *error_str;
|
||||
zval failure;
|
||||
@@ -199,10 +199,10 @@ static const char *fill_errors(zval *errors)
|
||||
}
|
||||
|
||||
zval error_type;
|
||||
ZVAL_OBJ(&error_type, zend_enum_get_case_cstr(uri_whatwg_url_validation_error_type_ce, error_str));
|
||||
zend_update_property_ex(uri_whatwg_url_validation_error_ce, Z_OBJ(error), ZSTR_KNOWN(ZEND_STR_TYPE), &error_type);
|
||||
ZVAL_OBJ(&error_type, zend_enum_get_case_cstr(php_uri_ce_whatwg_url_validation_error_type, error_str));
|
||||
zend_update_property_ex(php_uri_ce_whatwg_url_validation_error, Z_OBJ(error), ZSTR_KNOWN(ZEND_STR_TYPE), &error_type);
|
||||
|
||||
zend_update_property(uri_whatwg_url_validation_error_ce, Z_OBJ(error), ZEND_STRL("failure"), &failure);
|
||||
zend_update_property(php_uri_ce_whatwg_url_validation_error, Z_OBJ(error), ZEND_STRL("failure"), &failure);
|
||||
|
||||
if (Z_TYPE(failure) == IS_TRUE) {
|
||||
result = error_str;
|
||||
@@ -219,7 +219,7 @@ static void throw_invalid_url_exception_during_write(zval *errors, const char *c
|
||||
zval err;
|
||||
const char *reason = fill_errors(&err);
|
||||
zend_object *exception = zend_throw_exception_ex(
|
||||
uri_whatwg_invalid_url_exception_ce,
|
||||
php_uri_ce_whatwg_invalid_url_exception,
|
||||
0,
|
||||
"The specified %s is malformed%s%s%s",
|
||||
component,
|
||||
@@ -565,7 +565,7 @@ lxb_url_t *php_uri_parser_whatwg_parse_ex(const char *uri_str, size_t uri_str_le
|
||||
zval err;
|
||||
const char *reason = fill_errors(&err);
|
||||
if (url == NULL && !silent) {
|
||||
zend_object *exception = zend_throw_exception_ex(uri_whatwg_invalid_url_exception_ce, 0, "The specified URI is malformed%s%s%s", reason ? " (" : "", reason ? reason : "", reason ? ")" : "");
|
||||
zend_object *exception = zend_throw_exception_ex(php_uri_ce_whatwg_invalid_url_exception, 0, "The specified URI is malformed%s%s%s", reason ? " (" : "", reason ? reason : "", reason ? ")" : "");
|
||||
zend_update_property(exception->ce, exception, ZEND_STRL("errors"), &err);
|
||||
}
|
||||
if (errors != NULL) {
|
||||
|
||||
@@ -741,7 +741,7 @@ static ZEND_FUNCTION(zend_test_uri_parser)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
uri_internal_t *uri = php_uri_parse(parser, ZSTR_VAL(uri_string), ZSTR_LEN(uri_string), false);
|
||||
php_uri_internal *uri = php_uri_parse(parser, ZSTR_VAL(uri_string), ZSTR_LEN(uri_string), false);
|
||||
if (uri == NULL) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user