Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions ext/lexbor/lexbor/url/url.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,10 +613,6 @@ lxb_url_percent_decode(const lxb_char_t *data, const lxb_char_t *end,
lexbor_str_t *str, lexbor_mraw_t *mraw,
lxb_url_host_opt_t *opt);

static lxb_status_t
lxb_url_percent_decode_plus(const lxb_char_t *data, const lxb_char_t *end,
lexbor_str_t *str, lexbor_mraw_t *mraw);

static const lxb_char_t *
lxb_url_path_part_by_index(const lxb_url_t *url, size_t index,
size_t *out_length);
Expand Down Expand Up @@ -4071,7 +4067,7 @@ lxb_url_percent_decode(const lxb_char_t *data, const lxb_char_t *end,
return LXB_STATUS_OK;
}

static lxb_status_t
lxb_status_t
lxb_url_percent_decode_plus(const lxb_char_t *data, const lxb_char_t *end,
lexbor_str_t *str, lexbor_mraw_t *mraw)
{
Expand Down
4 changes: 4 additions & 0 deletions ext/lexbor/lexbor/url/url.h
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,10 @@ lxb_url_get(lxb_url_parser_t *parser)
return parser->url;
}

lxb_status_t
lxb_url_percent_decode_plus(const lxb_char_t *data, const lxb_char_t *end,
lexbor_str_t *str, lexbor_mraw_t *mraw);


#ifdef __cplusplus
} /* extern "C" */
Expand Down
3 changes: 2 additions & 1 deletion ext/uri/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ PHP_INSTALL_HEADERS([ext/uri], m4_normalize([
php_uri.h
php_uri_common.h
php_uri_decl.h
php_uri_query.h
uri_parser_rfc3986.h
uri_parser_whatwg.h
uri_parser_php_parse_url.h
Expand Down Expand Up @@ -39,7 +40,7 @@ else
PHP_EVAL_INCLINE([$LIBURIPARSER_CFLAGS])
fi

PHP_NEW_EXTENSION(uri, [php_uri.c php_uri_common.c uri_parser_rfc3986.c uri_parser_whatwg.c uri_parser_php_parse_url.c $URIPARSER_SOURCES], [no],,[$URI_CFLAGS])
PHP_NEW_EXTENSION(uri, [php_uri.c php_uri_common.c php_uri_query.c uri_parser_rfc3986.c uri_parser_whatwg.c uri_parser_php_parse_url.c $URIPARSER_SOURCES], [no],,[$URI_CFLAGS])
PHP_ADD_EXTENSION_DEP(uri, lexbor)

if test "$PHP_EXTERNAL_URIPARSER" = "no"; then
Expand Down
53 changes: 40 additions & 13 deletions ext/uri/php_uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "ext/standard/info.h"

#include "php_uri.h"
#include "php_uri_query.h"
#include "uri_parser_whatwg.h"
#include "uri_parser_rfc3986.h"
#include "uri_parser_php_parse_url.h"
Expand All @@ -39,13 +40,17 @@ 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_query_params;
zend_class_entry *php_uri_ce_query_param_options;
zend_class_entry *php_uri_ce_whatwg_url_host_type;
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 zend_object_handlers object_handlers_query_params;
static zend_object_handlers object_handlers_query_param_options;

typedef zend_result (*php_uri_component_validator_string)(const zend_string *component);
typedef zend_result (*php_uri_component_validator_long)(zend_long component);
Expand Down Expand Up @@ -1312,6 +1317,19 @@ PHPAPI zend_result php_uri_parser_register(const php_uri_parser *uri_parser)
return result;
}

static PHP_MINFO_FUNCTION(uri)
{
php_info_print_table_start();
php_info_print_table_row(2, "URI support", "active");
#ifdef URI_STATIC_BUILD
php_info_print_table_row(2, "uriparser bundled version", URI_VER_ANSI);
#else
php_info_print_table_row(2, "uriparser compiled version", URI_VER_ANSI);
php_info_print_table_row(2, "uriparser loaded version", uriBaseRuntimeVersionA());
#endif
php_info_print_table_end();
}

static PHP_MINIT_FUNCTION(uri)
{
php_uri_ce_rfc3986_uri_builder = register_class_Uri_Rfc3986_UriBuilder();
Expand Down Expand Up @@ -1339,6 +1357,28 @@ static PHP_MINIT_FUNCTION(uri)
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_query_params = register_class_Uri_QueryParams(zend_ce_aggregate, zend_ce_countable);
php_uri_ce_query_params->create_object = php_uri_object_query_params_create_object;
php_uri_ce_query_params->get_iterator = php_uri_object_query_params_get_iterator;
php_uri_ce_query_params->default_object_handlers = &object_handlers_query_params;
memcpy(&object_handlers_query_params, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
object_handlers_query_params.offset = offsetof(php_uri_query_params_object, std);
object_handlers_query_params.free_obj = php_uri_query_params_object_handler_free;
object_handlers_query_params.clone_obj = php_uri_query_params_object_handler_clone;

php_uri_ce_query_param_options = register_class_Uri_QueryParamOptions();
php_uri_ce_query_param_options->create_object = php_uri_object_create_query_param_options;
memcpy(&object_handlers_query_param_options, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
object_handlers_query_param_options.offset = offsetof(php_uri_query_param_options_object, std);
object_handlers_query_param_options.free_obj = php_uri_query_param_options_object_handler_free;
object_handlers_query_param_options.clone_obj = php_uri_query_param_options_object_handler_clone;
object_handlers_query_param_options.has_property = php_uri_query_param_options_object_handler_has_property;
object_handlers_query_param_options.read_property = php_uri_query_param_options_object_handler_read_property;
object_handlers_query_param_options.write_property = php_uri_query_param_options_object_handler_write_property;
object_handlers_query_param_options.unset_property = php_uri_query_param_options_object_handler_unset_property;
object_handlers_query_param_options.get_property_ptr_ptr = php_uri_query_param_options_object_handler_get_property_ptr_ptr;

php_uri_ce_whatwg_invalid_url_exception = register_class_Uri_WhatWg_InvalidUrlException(php_uri_ce_invalid_uri_exception);
php_uri_ce_whatwg_url_host_type = register_class_Uri_WhatWg_UrlHostType();
php_uri_ce_whatwg_url_validation_error = register_class_Uri_WhatWg_UrlValidationError();
Expand All @@ -1361,19 +1401,6 @@ static PHP_MINIT_FUNCTION(uri)
return SUCCESS;
}

static PHP_MINFO_FUNCTION(uri)
{
php_info_print_table_start();
php_info_print_table_row(2, "URI support", "active");
#ifdef URI_STATIC_BUILD
php_info_print_table_row(2, "uriparser bundled version", URI_VER_ANSI);
#else
php_info_print_table_row(2, "uriparser compiled version", URI_VER_ANSI);
php_info_print_table_row(2, "uriparser loaded version", uriBaseRuntimeVersionA());
#endif
php_info_print_table_end();
}

static PHP_MSHUTDOWN_FUNCTION(uri)
{
zend_hash_destroy(&uri_parsers);
Expand Down
79 changes: 79 additions & 0 deletions ext/uri/php_uri.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,85 @@ enum UriComparisonMode
case IncludeFragment;
case ExcludeFragment;
}

final readonly class QueryParamOptions
{
/** @virtual */
public int $parsingMaxQueryStringLength;
/** @virtual */
public int $parsingMaxParamCount;
/** @virtual */
public string $trueValue;
/** @virtual */
public string $falseValue;
/** @virtual */
public bool $useNullAsEmptyString;

public function __construct(
int $parsingMaxQueryStringLength = 10000,
int $parsingMaxParamCount = 1000,
string $trueValue = "0",
string $falseValue = "0",
bool $useNullAsEmptyString = false
) {}

public function __debugInfo(): array {}
}

final readonly class QueryParams implements \IteratorAggregate, \Countable
{
private QueryParamOptions $options;

public static function parseRfc1866(string $queryString, ?QueryParamOptions $options = null): \Uri\QueryParams {}

public static function parseRfc3986(string $queryString, ?QueryParamOptions $options = null): ?\Uri\QueryParams {}

public static function parseWhatWg(string $queryString, ?QueryParamOptions $options = null): \Uri\QueryParams {}

public static function fromArray(array $queryParams, ?QueryParamOptions $options = null): \Uri\QueryParams {}

public function __construct(?QueryParamOptions $options = null) {}

public function append(string $name, mixed $value): static {}

public function delete(string $name): static {}

public function deleteValue(string $name, ?string $value): static {}

public function has(string $name): bool {}

public function hasValue(string $name, mixed $value): bool {}

public function getFirst(string $name): ?string {}

public function getLast(string $name): ?string {}

public function getAll(string $name): array {}

public function list(): array {}

public function getIterator(): \Traversable {}

public function count(): int {}

public function set(string $name, mixed $value): static {}

public function sort(): static {}

public function toArray(): array {}

public function toRfc1866String(): string {}

public function toRfc3986String(): string {}

public function toWhatWgString(): string {}

public function __serialize(): array {}

public function __unserialize(array $data): void {}

public function __debugInfo(): array {}
}
}

namespace Uri\Rfc3986 {
Expand Down
Loading
Loading