Skip to content

Commit ac9af23

Browse files
committed
Additional review fixes + uriparser sync with latest master
1 parent 61c42ab commit ac9af23

File tree

8 files changed

+23
-84
lines changed

8 files changed

+23
-84
lines changed

ext/uri/php_uri.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static PHP_MINFO_FUNCTION(uri)
5353
{
5454
php_info_print_table_start();
5555
php_info_print_table_row(2, "uri support", "active");
56+
php_info_print_table_row(2, "uriparser library version", URIPARSER_VERSION);
5657
php_info_print_table_end();
5758
}
5859

@@ -64,9 +65,6 @@ static PHP_MSHUTDOWN_FUNCTION(uri)
6465

6566
PHP_RINIT_FUNCTION(uri)
6667
{
67-
#if defined(COMPILE_DL_URI) && defined(ZTS)
68-
ZEND_TSRMLS_CACHE_UPDATE();
69-
#endif
7068

7169
return SUCCESS;
7270
}
@@ -89,10 +87,3 @@ zend_module_entry uri_module_entry = {
8987
PHP_VERSION, /* Version */
9088
STANDARD_MODULE_PROPERTIES
9189
};
92-
93-
#ifdef COMPILE_DL_URI
94-
#ifdef ZTS
95-
ZEND_TSRMLS_CACHE_DEFINE()
96-
#endif
97-
ZEND_GET_MODULE(uri)
98-
#endif

ext/uri/php_uri.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,5 @@
2020
extern zend_module_entry uri_module_entry;
2121
#define phpext_uri_ptr &uri_module_entry
2222

23-
#if defined(ZTS) && defined(COMPILE_DL_URI)
24-
ZEND_TSRMLS_CACHE_EXTERN()
25-
#endif
2623

2724
#endif

ext/uri/uriparser/include/uriparser/Uri.h

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ extern "C" {
8585
# include "UriBase.h"
8686
#endif
8787

88-
extern const URI_CHAR * const URI_FUNC(SafeToPointTo);
88+
8989

9090
/**
9191
* Specifies a range of characters within a string.
@@ -200,11 +200,7 @@ typedef struct URI_TYPE(QueryListStruct) {
200200
struct URI_TYPE(QueryListStruct) * next; /**< Pointer to the next key/value pair in the list, can be NULL if last already */
201201
} URI_TYPE(QueryList); /**< @copydoc UriQueryListStructA */
202202

203-
URI_PUBLIC UriBool URI_FUNC(IsHostSet)(const URI_TYPE(Uri) * uri);
204203

205-
URI_PUBLIC UriBool URI_FUNC(PushPathSegment)(URI_TYPE(ParserState) * state,
206-
const URI_CHAR * first, const URI_CHAR * afterLast,
207-
UriMemoryManager * memory);
208204

209205
/**
210206
* Parses a RFC 3986 %URI.
@@ -354,7 +350,7 @@ URI_PUBLIC int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri,
354350

355351

356352
/**
357-
* Percent-encodes all unreserved characters from the input string and
353+
* Percent-encodes all but unreserved characters from the input string and
358354
* writes the encoded version to the output string.
359355
*
360356
* NOTE: Be sure to allocate <b>3 times</b> the space of the input buffer for
@@ -388,7 +384,7 @@ URI_PUBLIC URI_CHAR * URI_FUNC(EscapeEx)(const URI_CHAR * inFirst,
388384

389385

390386
/**
391-
* Percent-encodes all unreserved characters from the input string and
387+
* Percent-encodes all but unreserved characters from the input string and
392388
* writes the encoded version to the output string.
393389
*
394390
* NOTE: Be sure to allocate <b>3 times</b> the space of the input buffer for
@@ -465,7 +461,7 @@ URI_PUBLIC const URI_CHAR * URI_FUNC(UnescapeInPlace)(URI_CHAR * inout);
465461

466462
/**
467463
* Performs reference resolution as described in
468-
* <a href="http://tools.ietf.org/html/rfc3986#section-5.2.2">section 5.2.2 of RFC 3986</a>.
464+
* <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.2">section 5.2.2 of RFC 3986</a>.
469465
* Uses default libc-based memory manager.
470466
* NOTE: On success you have to call uriFreeUriMembersA on \p absoluteDest manually later.
471467
*
@@ -488,7 +484,7 @@ URI_PUBLIC int URI_FUNC(AddBaseUri)(URI_TYPE(Uri) * absoluteDest,
488484

489485
/**
490486
* Performs reference resolution as described in
491-
* <a href="http://tools.ietf.org/html/rfc3986#section-5.2.2">section 5.2.2 of RFC 3986</a>.
487+
* <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.2">section 5.2.2 of RFC 3986</a>.
492488
* Uses default libc-based memory manager.
493489
* NOTE: On success you have to call uriFreeUriMembersA on \p absoluteDest manually later.
494490
*
@@ -512,7 +508,7 @@ URI_PUBLIC int URI_FUNC(AddBaseUriEx)(URI_TYPE(Uri) * absoluteDest,
512508

513509
/**
514510
* Performs reference resolution as described in
515-
* <a href="http://tools.ietf.org/html/rfc3986#section-5.2.2">section 5.2.2 of RFC 3986</a>.
511+
* <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.2">section 5.2.2 of RFC 3986</a>.
516512
* NOTE: On success you have to call uriFreeUriMembersMmA on \p absoluteDest manually later.
517513
*
518514
* @param absoluteDest <b>OUT</b>: Result %URI
@@ -628,10 +624,10 @@ URI_PUBLIC int URI_FUNC(ToStringCharsRequired)(const URI_TYPE(Uri) * uri,
628624

629625
/**
630626
* Converts a %URI structure back to text as described in
631-
* <a href="http://tools.ietf.org/html/rfc3986#section-5.3">section 5.3 of RFC 3986</a>.
627+
* <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-5.3">section 5.3 of RFC 3986</a>.
632628
*
633629
* NOTE: Scheme-based normalization
634-
* (<a href="http://tools.ietf.org/html/rfc3986#section-6.2.3">section 6.2.3 of RFC 3986</a>)
630+
* (<a href="https://datatracker.ietf.org/doc/html/rfc3986#section-6.2.3">section 6.2.3 of RFC 3986</a>)
635631
* is not applied and is considered a responsibility of the application using uriparser.
636632
*
637633
* @param dest <b>OUT</b>: Output destination

ext/uri/uriparser/src/UriCommon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,8 @@ unsigned char URI_FUNC(HexdigToInt)(URI_CHAR hexdig) {
431431

432432

433433
URI_CHAR URI_FUNC(HexToLetter)(unsigned int value) {
434-
/* Uppercase recommended in section 2.1. of RFC 3986 *
435-
* http://tools.ietf.org/html/rfc3986#section-2.1 */
434+
/* Uppercase recommended in section 2.1. of RFC 3986 *
435+
* https://datatracker.ietf.org/doc/html/rfc3986#section-2.1 */
436436
return URI_FUNC(HexToLetterEx)(value, URI_TRUE);
437437
}
438438

ext/uri/uriparser/src/UriCommon.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070

7171
/* Used to point to from empty path segments.
7272
* X.first and X.afterLast must be the same non-NULL value then. */
73+
extern const URI_CHAR * const URI_FUNC(SafeToPointTo);
7374
extern const URI_CHAR * const URI_FUNC(ConstPwd);
7475
extern const URI_CHAR * const URI_FUNC(ConstParent);
7576

@@ -90,6 +91,8 @@ unsigned char URI_FUNC(HexdigToInt)(URI_CHAR hexdig);
9091
URI_CHAR URI_FUNC(HexToLetter)(unsigned int value);
9192
URI_CHAR URI_FUNC(HexToLetterEx)(unsigned int value, UriBool uppercase);
9293

94+
UriBool URI_FUNC(IsHostSet)(const URI_TYPE(Uri) * uri);
95+
9396
UriBool URI_FUNC(CopyPath)(URI_TYPE(Uri) * dest, const URI_TYPE(Uri) * source,
9497
UriMemoryManager * memory);
9598
UriBool URI_FUNC(CopyAuthority)(URI_TYPE(Uri) * dest,

ext/uri/uriparser/src/UriConfig.h

Lines changed: 0 additions & 51 deletions
This file was deleted.

ext/uri/uriparser/src/UriNormalize.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static UriBool URI_FUNC(ContainsUglyPercentEncoding)(const URI_CHAR * first,
104104

105105
static void URI_FUNC(LowercaseInplace)(const URI_CHAR * first,
106106
const URI_CHAR * afterLast);
107-
static void URI_FUNC(LowercaseInplaceAfterPercentEncoding)(const URI_CHAR * first,
107+
static void URI_FUNC(LowercaseInplaceExceptPercentEncoding)(const URI_CHAR * first,
108108
const URI_CHAR * afterLast);
109109
static UriBool URI_FUNC(LowercaseMalloc)(const URI_CHAR ** first,
110110
const URI_CHAR ** afterLast, UriMemoryManager * memory);
@@ -247,7 +247,7 @@ static URI_INLINE void URI_FUNC(LowercaseInplace)(const URI_CHAR * first,
247247

248248

249249

250-
static URI_INLINE void URI_FUNC(LowercaseInplaceAfterPercentEncoding)(const URI_CHAR * first,
250+
static URI_INLINE void URI_FUNC(LowercaseInplaceExceptPercentEncoding)(const URI_CHAR * first,
251251
const URI_CHAR * afterLast) {
252252
if ((first != NULL) && (afterLast != NULL) && (afterLast > first)) {
253253
URI_CHAR * i = (URI_CHAR *)first;
@@ -256,6 +256,9 @@ static URI_INLINE void URI_FUNC(LowercaseInplaceAfterPercentEncoding)(const URI_
256256
if ((*i >= _UT('A')) && (*i <=_UT('Z'))) {
257257
*i = (URI_CHAR)(*i + lowerUpperDiff);
258258
} else if (*i == _UT('%')) {
259+
if (i + 3 >= afterLast) {
260+
return;
261+
}
259262
i += 2;
260263
}
261264
}
@@ -634,7 +637,7 @@ static URI_INLINE int URI_FUNC(NormalizeSyntaxEngine)(URI_TYPE(Uri) * uri,
634637
uri->hostText.afterLast = uri->hostData.ipFuture.afterLast;
635638
} else if ((uri->hostText.first != NULL)
636639
&& (uri->hostData.ip4 == NULL)) {
637-
/* Regname and IPv6 */
640+
/* Regname or IPv6 */
638641
if (uri->owner) {
639642
URI_FUNC(FixPercentEncodingInplace)(uri->hostText.first,
640643
&(uri->hostText.afterLast));
@@ -649,7 +652,7 @@ static URI_INLINE int URI_FUNC(NormalizeSyntaxEngine)(URI_TYPE(Uri) * uri,
649652
doneMask |= URI_NORMALIZE_HOST;
650653
}
651654

652-
URI_FUNC(LowercaseInplaceAfterPercentEncoding)(uri->hostText.first,
655+
URI_FUNC(LowercaseInplaceExceptPercentEncoding)(uri->hostText.first,
653656
uri->hostText.afterLast);
654657
}
655658
}

ext/uri/uriparser/src/UriParse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static void URI_FUNC(OnExitPartHelperTwo)(URI_TYPE(ParserState) * state);
196196

197197
static void URI_FUNC(ResetParserStateExceptUri)(URI_TYPE(ParserState) * state);
198198

199-
UriBool URI_FUNC(PushPathSegment)(URI_TYPE(ParserState) * state,
199+
static UriBool URI_FUNC(PushPathSegment)(URI_TYPE(ParserState) * state,
200200
const URI_CHAR * first, const URI_CHAR * afterLast,
201201
UriMemoryManager * memory);
202202

@@ -2119,7 +2119,7 @@ static URI_INLINE void URI_FUNC(ResetParserStateExceptUri)(URI_TYPE(ParserState)
21192119

21202120

21212121

2122-
UriBool URI_FUNC(PushPathSegment)(
2122+
static URI_INLINE UriBool URI_FUNC(PushPathSegment)(
21232123
URI_TYPE(ParserState) * state, const URI_CHAR * first,
21242124
const URI_CHAR * afterLast, UriMemoryManager * memory) {
21252125
URI_TYPE(PathSegment) * segment = memory->calloc(memory, 1, sizeof(URI_TYPE(PathSegment)));

0 commit comments

Comments
 (0)