Skip to content

Commit 731137b

Browse files
committed
Update uriparser
1 parent b487bb8 commit 731137b

21 files changed

+438
-62
lines changed

ext/uri/config.m4

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ $URIPARSER_DIR/src/UriEscape.c $URIPARSER_DIR/src/UriFile.c $URIPARSER_DIR/src/U
1818
$URIPARSER_DIR/src/UriMemory.c $URIPARSER_DIR/src/UriNormalize.c $URIPARSER_DIR/src/UriNormalizeBase.c \
1919
$URIPARSER_DIR/src/UriParse.c $URIPARSER_DIR/src/UriParseBase.c $URIPARSER_DIR/src/UriQuery.c \
2020
$URIPARSER_DIR/src/UriRecompose.c $URIPARSER_DIR/src/UriResolve.c $URIPARSER_DIR/src/UriSetFragment.c \
21-
$URIPARSER_DIR/src/UriSetHostCommon.c $URIPARSER_DIR/src/UriSetHostIp4.c $URIPARSER_DIR/src/UriSetHostIp6.c \
22-
$URIPARSER_DIR/src/UriSetHostIpFuture.c $URIPARSER_DIR/src/UriSetHostRegName.c $URIPARSER_DIR/src/UriSetPath.c \
23-
$URIPARSER_DIR/src/UriSetPort.c $URIPARSER_DIR/src/UriSetQuery.c $URIPARSER_DIR/src/UriSetScheme.c \
24-
$URIPARSER_DIR/src/UriSetUserInfo.c $URIPARSER_DIR/src/UriShorten.c"
21+
$URIPARSER_DIR/src/UriSetHostAuto.c $URIPARSER_DIR/src/UriSetHostCommon.c $URIPARSER_DIR/src/UriSetHostIp4.c \
22+
$URIPARSER_DIR/src/UriSetHostIp6.c $URIPARSER_DIR/src/UriSetHostIpFuture.c $URIPARSER_DIR/src/UriSetHostRegName.c \
23+
$URIPARSER_DIR/src/UriSetPath.c $URIPARSER_DIR/src/UriSetPort.c $URIPARSER_DIR/src/UriSetQuery.c \
24+
$URIPARSER_DIR/src/UriSetScheme.c $URIPARSER_DIR/src/UriSetUserInfo.c $URIPARSER_DIR/src/UriShorten.c"
2525

2626
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])
2727
PHP_ADD_EXTENSION_DEP(uri, lexbor)

ext/uri/config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ ADD_FLAG("CFLAGS_URI", "/D URI_STATIC_BUILD");
77
ADD_EXTENSION_DEP('uri', 'lexbor');
88
ADD_SOURCES("ext/uri/uriparser/src", "UriCommon.c UriCompare.c UriCopy.c UriEscape.c UriFile.c UriIp4.c UriIp4Base.c \
99
UriMemory.c UriNormalize.c UriNormalizeBase.c UriParse.c UriParseBase.c UriQuery.c UriRecompose.c UriResolve.c \
10-
UriSetFragment.c UriSetHostCommon.c UriSetHostIp4.c UriSetHostIp6.c UriSetHostIpFuture.c UriSetHostRegName.c \
10+
UriSetFragment.c UriSetHostAuto.c UriSetHostCommon.c UriSetHostIp4.c UriSetHostIp6.c UriSetHostIpFuture.c UriSetHostRegName.c \
1111
UriSetPath.c UriSetPort.c UriSetQuery.c UriSetScheme.c UriSetUserInfo.c UriShorten.c", "uri");
1212
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");

ext/uri/tests/026.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ $uri1 = Uri\Rfc3986\Uri::parse("https://example.com");
99
$uri2 = $uri1->withHost("test.com");
1010
$uri3 = $uri2->withHost("t%65st.com"); // test.com
1111
$uri4 = $uri3->withHost(null);
12+
$uri5 = $uri4->withHost("192.168.0.1");
13+
$uri6 = $uri5->withHost("[2001:db8:3333:4444:5555:6666:7777:8888]");
1214

1315
var_dump($uri1->getHost());
1416
var_dump($uri2->getHost());
1517
var_dump($uri3->getHost());
1618
var_dump($uri3->getRawHost());
1719
var_dump($uri4->getRawHost());
20+
var_dump($uri5->getRawHost());
21+
var_dump($uri6->getRawHost());
1822

1923
try {
2024
$uri3->withHost("test.com:8080");
@@ -55,10 +59,14 @@ try {
5559
$url1 = Uri\WhatWg\Url::parse("https://example.com");
5660
$url2 = $url1->withHost("test.com");
5761
$url3 = $url2->withHost("t%65st.com"); // test.com
62+
$url4 = $url3->withHost("192.168.0.1");
63+
$url5 = $url4->withHost("[2001:db8:3333:4444:5555:6666:7777:8888]");
5864

5965
var_dump($url1->getAsciiHost());
6066
var_dump($url2->getAsciiHost());
6167
var_dump($url3->getAsciiHost());
68+
var_dump($url4->getAsciiHost());
69+
var_dump($url5->getAsciiHost());
6270

6371
try {
6472
$url3->withHost("test.com:8080");
@@ -97,6 +105,8 @@ string(8) "test.com"
97105
string(8) "test.com"
98106
string(10) "t%65st.com"
99107
NULL
108+
string(11) "192.168.0.1"
109+
string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]"
100110
The specified host is malformed
101111
The specified host is malformed
102112
string(7) "foo.com"
@@ -105,6 +115,8 @@ The specified host is malformed
105115
string(11) "example.com"
106116
string(8) "test.com"
107117
string(8) "test.com"
118+
string(11) "192.168.0.1"
119+
string(40) "[2001:db8:3333:4444:5555:6666:7777:8888]"
108120
The specified host is malformed
109121
The specified host is malformed (DomainInvalidCodePoint)
110122
The specified host is malformed

ext/uri/tests/035.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ try {
1111
echo $e->getMessage() . "\n";
1212
}
1313

14+
$uri = new Uri\Rfc3986\Uri("https://example.com");
15+
try {
16+
$uri->withHost("exam\0ple.com");
17+
} catch (Error $e) {
18+
echo $e->getMessage() . "\n";
19+
}
20+
1421
try {
1522
new Uri\WhatWg\Url("https://exam\0ple.com");
1623
} catch (Error $e) {
@@ -27,5 +34,6 @@ try {
2734
?>
2835
--EXPECT--
2936
Uri\Rfc3986\Uri::__construct(): Argument #1 ($uri) must not contain any null bytes
37+
Uri\Rfc3986\Uri::withHost(): Argument #1 ($host) must not contain any null bytes
3038
Uri\WhatWg\Url::__construct(): Argument #1 ($uri) must not contain any null bytes
3139
Uri\WhatWg\Url::withHost(): Argument #1 ($host) must not contain any null bytes

ext/uri/uri_parser_rfc3986.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ static zend_result php_uri_parser_rfc3986_host_write(struct uri_internal_t *inte
253253
int result;
254254

255255
if (Z_TYPE_P(value) == IS_NULL) {
256-
result = uriSetHostRegNameMmA(uriparser_uri, NULL, NULL, mm);
256+
result = uriSetHostAutoMmA(uriparser_uri, NULL, NULL, mm);
257257
} else {
258-
result = uriSetHostRegNameMmA(uriparser_uri, Z_STRVAL_P(value), Z_STRVAL_P(value) + Z_STRLEN_P(value), mm);
258+
result = uriSetHostAutoMmA(uriparser_uri, Z_STRVAL_P(value), Z_STRVAL_P(value) + Z_STRLEN_P(value), mm);
259259
}
260260

261261
if (result != URI_SUCCESS) {

0 commit comments

Comments
 (0)