Skip to content
Open
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: 5 additions & 1 deletion ext/uri/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ URIPARSER_SOURCES="$URIPARSER_DIR/src/UriCommon.c $URIPARSER_DIR/src/UriCompare.
$URIPARSER_DIR/src/UriEscape.c $URIPARSER_DIR/src/UriFile.c $URIPARSER_DIR/src/UriIp4.c $URIPARSER_DIR/src/UriIp4Base.c \
$URIPARSER_DIR/src/UriMemory.c $URIPARSER_DIR/src/UriNormalize.c $URIPARSER_DIR/src/UriNormalizeBase.c \
$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"
$URIPARSER_DIR/src/UriRecompose.c $URIPARSER_DIR/src/UriResolve.c $URIPARSER_DIR/src/UriSetFragment.c \
$URIPARSER_DIR/src/UriSetHostAuto.c $URIPARSER_DIR/src/UriSetHostCommon.c $URIPARSER_DIR/src/UriSetHostIp4.c \
$URIPARSER_DIR/src/UriSetHostIp6.c $URIPARSER_DIR/src/UriSetHostIpFuture.c $URIPARSER_DIR/src/UriSetHostRegName.c \
$URIPARSER_DIR/src/UriSetPath.c $URIPARSER_DIR/src/UriSetPort.c $URIPARSER_DIR/src/UriSetQuery.c \
$URIPARSER_DIR/src/UriSetScheme.c $URIPARSER_DIR/src/UriSetUserInfo.c $URIPARSER_DIR/src/UriShorten.c"

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],,[-I$ext_srcdir/$URIPARSER_DIR/include -DURI_STATIC_BUILD -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1])
PHP_ADD_EXTENSION_DEP(uri, lexbor)
Expand Down
5 changes: 4 additions & 1 deletion ext/uri/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ AC_DEFINE("URI_NO_UNICODE", 1, "Define to 1 for disabling unicode support of uri
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");
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 \
UriSetFragment.c UriSetHostAuto.c UriSetHostCommon.c UriSetHostIp4.c UriSetHostIp6.c UriSetHostIpFuture.c UriSetHostRegName.c \
UriSetPath.c UriSetPort.c UriSetQuery.c UriSetScheme.c UriSetUserInfo.c UriShorten.c", "uri");
PHP_INSTALL_HEADERS("ext/uri", "php_uri.h php_uri_common.h uri_parser_rfc3986.h uri_parser_whatwg.h uri_parser_php_parse_url.h uriparser/src uriparser/include");
96 changes: 71 additions & 25 deletions ext/uri/php_uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,12 @@ PHP_METHOD(Uri_Rfc3986_Uri, getRawScheme)
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_SCHEME, URI_COMPONENT_READ_RAW);
}

static void read_uriparser_userinfo(INTERNAL_FUNCTION_PARAMETERS, uri_component_read_mode_t read_mode)
PHP_METHOD(Uri_Rfc3986_Uri, withScheme)
{
uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_SCHEME);
}

static void rfc3986_userinfo_read(INTERNAL_FUNCTION_PARAMETERS, uri_component_read_mode_t read_mode)
{
ZEND_PARSE_PARAMETERS_NONE();

Expand All @@ -515,12 +520,48 @@ static void read_uriparser_userinfo(INTERNAL_FUNCTION_PARAMETERS, uri_component_

PHP_METHOD(Uri_Rfc3986_Uri, getUserInfo)
{
read_uriparser_userinfo(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_COMPONENT_READ_NORMALIZED_ASCII);
rfc3986_userinfo_read(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_COMPONENT_READ_NORMALIZED_ASCII);
}

PHP_METHOD(Uri_Rfc3986_Uri, getRawUserInfo)
{
read_uriparser_userinfo(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_COMPONENT_READ_RAW);
rfc3986_userinfo_read(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_COMPONENT_READ_RAW);
}

PHP_METHOD(Uri_Rfc3986_Uri, withUserInfo)
{
zend_string *value;

ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_PATH_STR_OR_NULL(value)
ZEND_PARSE_PARAMETERS_END();

zval zv;
if (value == NULL) {
ZVAL_NULL(&zv);
} else {
ZVAL_STR(&zv, value);
}

uri_internal_t *internal_uri = Z_URI_INTERNAL_P(ZEND_THIS);
URI_ASSERT_INITIALIZATION(internal_uri);

zend_object *new_object = uri_clone_obj_handler(Z_OBJ_P(ZEND_THIS));
ZEND_ASSERT(new_object != NULL);

uri_internal_t *new_internal_uri = uri_internal_from_obj(new_object);
URI_ASSERT_INITIALIZATION(new_internal_uri);

zval errors;
ZVAL_UNDEF(&errors);
if (UNEXPECTED(php_uri_parser_rfc3986_userinfo_write(new_internal_uri, &zv, NULL) == FAILURE)) {
zval_ptr_dtor(&errors);
zend_object_release(new_object);
RETURN_THROWS();
}

ZEND_ASSERT(Z_ISUNDEF(errors));
RETVAL_OBJ(new_object);
}

PHP_METHOD(Uri_Rfc3986_Uri, getUsername)
Expand Down Expand Up @@ -553,11 +594,21 @@ PHP_METHOD(Uri_Rfc3986_Uri, getRawHost)
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_HOST, URI_COMPONENT_READ_RAW);
}

PHP_METHOD(Uri_Rfc3986_Uri, withHost)
{
uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_HOST);
}

PHP_METHOD(Uri_Rfc3986_Uri, getPort)
{
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_PORT, URI_COMPONENT_READ_RAW);
}

PHP_METHOD(Uri_Rfc3986_Uri, withPort)
{
uri_write_component_long_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_PORT);
}

PHP_METHOD(Uri_Rfc3986_Uri, getPath)
{
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_PATH, URI_COMPONENT_READ_NORMALIZED_ASCII);
Expand All @@ -568,6 +619,11 @@ PHP_METHOD(Uri_Rfc3986_Uri, getRawPath)
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_PATH, URI_COMPONENT_READ_RAW);
}

PHP_METHOD(Uri_Rfc3986_Uri, withPath)
{
uri_write_component_str(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_PATH);
}

PHP_METHOD(Uri_Rfc3986_Uri, getQuery)
{
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_QUERY, URI_COMPONENT_READ_NORMALIZED_ASCII);
Expand All @@ -578,6 +634,11 @@ PHP_METHOD(Uri_Rfc3986_Uri, getRawQuery)
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_QUERY, URI_COMPONENT_READ_RAW);
}

PHP_METHOD(Uri_Rfc3986_Uri, withQuery)
{
uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_QUERY);
}

PHP_METHOD(Uri_Rfc3986_Uri, getFragment)
{
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_FRAGMENT, URI_COMPONENT_READ_NORMALIZED_ASCII);
Expand All @@ -588,6 +649,11 @@ PHP_METHOD(Uri_Rfc3986_Uri, getRawFragment)
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_FRAGMENT, URI_COMPONENT_READ_RAW);
}

PHP_METHOD(Uri_Rfc3986_Uri, withFragment)
{
uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_FRAGMENT);
}

static void throw_cannot_recompose_uri_to_string(zend_object *object)
{
zend_throw_exception_ex(NULL, 0, "Cannot recompose %s to a string", ZSTR_VAL(object->ce->name));
Expand Down Expand Up @@ -833,29 +899,9 @@ PHP_METHOD(Uri_WhatWg_Url, getUnicodeHost)
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_HOST, URI_COMPONENT_READ_NORMALIZED_UNICODE);
}

PHP_METHOD(Uri_WhatWg_Url, withHost)
{
uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_HOST);
}

PHP_METHOD(Uri_WhatWg_Url, withPort)
{
uri_write_component_long_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_PORT);
}

PHP_METHOD(Uri_WhatWg_Url, withPath)
PHP_METHOD(Uri_WhatWg_Url, getFragment)
{
uri_write_component_str(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_PATH);
}

PHP_METHOD(Uri_WhatWg_Url, withQuery)
{
uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_QUERY);
}

PHP_METHOD(Uri_WhatWg_Url, withFragment)
{
uri_write_component_str_or_null(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_FRAGMENT);
uri_read_component(INTERNAL_FUNCTION_PARAM_PASSTHRU, URI_PROPERTY_NAME_FRAGMENT, URI_COMPONENT_READ_NORMALIZED_UNICODE);
}

PHP_METHOD(Uri_WhatWg_Url, equals)
Expand Down
19 changes: 19 additions & 0 deletions ext/uri/php_uri.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ public function getScheme(): ?string {}

public function getRawScheme(): ?string {}

public function withScheme(?string $scheme): static {}

public function getUserInfo(): ?string {}

public function getRawUserInfo(): ?string {}

public function withUserInfo(#[\SensitiveParameter] ?string $userinfo): static {}

public function getUsername(): ?string {}

public function getRawUsername(): ?string {}
Expand All @@ -48,20 +52,30 @@ public function getHost(): ?string {}

public function getRawHost(): ?string {}

public function withHost(?string $host): static {}

public function getPort(): ?int {}

public function withPort(?int $port): static {}

public function getPath(): string {}

public function getRawPath(): string {}

public function withPath(string $path): static {}

public function getQuery(): ?string {}

public function getRawQuery(): ?string {}

public function withQuery(?string $query): static {}

public function getFragment(): ?string {}

public function getRawFragment(): ?string {}

public function withFragment(?string $fragment): static {}

public function equals(\Uri\Rfc3986\Uri $uri, \Uri\UriComparisonMode $comparisonMode = \Uri\UriComparisonMode::ExcludeFragment): bool {}

public function toString(): string {}
Expand Down Expand Up @@ -157,26 +171,31 @@ public function getAsciiHost(): ?string {}

public function getUnicodeHost(): ?string {}

/** @implementation-alias Uri\Rfc3986\Uri::withHost */
public function withHost(?string $host): static {}

/** @implementation-alias Uri\Rfc3986\Uri::getPort */
public function getPort(): ?int {}

/** @implementation-alias Uri\Rfc3986\Uri::withPort */
public function withPort(?int $port): static {}

/** @implementation-alias Uri\Rfc3986\Uri::getPath */
public function getPath(): string {}

/** @implementation-alias Uri\Rfc3986\Uri::withPath */
public function withPath(string $path): static {}

/** @implementation-alias Uri\Rfc3986\Uri::getQuery */
public function getQuery(): ?string {}

/** @implementation-alias Uri\Rfc3986\Uri::withQuery */
public function withQuery(?string $query): static {}

/** @implementation-alias Uri\Rfc3986\Uri::getFragment */
public function getFragment(): ?string {}

/** @implementation-alias Uri\Rfc3986\Uri::withFragment */
public function withFragment(?string $fragment): static {}

public function equals(\Uri\WhatWg\Url $url, \Uri\UriComparisonMode $comparisonMode = \Uri\UriComparisonMode::ExcludeFragment): bool {}
Expand Down
Loading