Skip to content

Commit

Permalink
Update bundled liburiparser to version 0.9.8.
Browse files Browse the repository at this point in the history
  • Loading branch information
enzo1982 committed May 9, 2024
1 parent bca49e1 commit 3676eb2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
32 changes: 27 additions & 5 deletions components/playlist/xspf/uriparser/Uri.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* 4bf720e0ca97527a28e4c30f1c35b36a0b5f2697265c5ddc81080eaab4344ef2 (0.9.7+)
/* e8e2c75d033ddfe256fe87c3fd5a330a6f2c9cbb376ebd83a1b3263e804c766a (0.9.8+)
*
* uriparser - RFC 3986 URI parsing library
*
Expand Down Expand Up @@ -352,10 +352,19 @@ URI_PUBLIC int URI_FUNC(FreeUriMembersMm)(URI_TYPE(Uri) * uri,
/**
* Percent-encodes all unreserved characters from the input string and
* writes the encoded version to the output string.
* Be sure to allocate <b>3 times</b> the space of the input buffer for
*
* NOTE: Be sure to allocate <b>3 times</b> the space of the input buffer for
* the output buffer for <c>normalizeBreaks == URI_FALSE</c> and <b>6 times</b>
* the space for <c>normalizeBreaks == URI_TRUE</c>
* (since e.g. "\x0d" becomes "%0D%0A" in that case)
* (since e.g. "\x0d" becomes "%0D%0A" in that case).
*
* NOTE: The implementation treats (both <c>char</c> and) <c>wchar_t</c> units
* as code point integers, which works well for code points <c>U+0001</c> to <c>U+00ff</c>
* in host-native endianness but nothing more;
* in particular, using <c>uriEscapeExW</c> with arbitrary Unicode input will
* not produce healthy results.
* Passing UTF-8 input to <c>uriEscapeExA</c> may be useful in some scenarios.
* Keep in mind that uriparser is about %URI (RFC 3986) not %IRI (RFC 3987).
*
* @param inFirst <b>IN</b>: Pointer to first character of the input text
* @param inAfterLast <b>IN</b>: Pointer after the last character of the input text
Expand All @@ -377,10 +386,19 @@ URI_PUBLIC URI_CHAR * URI_FUNC(EscapeEx)(const URI_CHAR * inFirst,
/**
* Percent-encodes all unreserved characters from the input string and
* writes the encoded version to the output string.
* Be sure to allocate <b>3 times</b> the space of the input buffer for
*
* NOTE: Be sure to allocate <b>3 times</b> the space of the input buffer for
* the output buffer for <c>normalizeBreaks == URI_FALSE</c> and <b>6 times</b>
* the space for <c>normalizeBreaks == URI_TRUE</c>
* (since e.g. "\x0d" becomes "%0D%0A" in that case)
* (since e.g. "\x0d" becomes "%0D%0A" in that case).
*
* NOTE: The implementation treats (both <c>char</c> and) <c>wchar_t</c> units
* as code point integers, which works well for code points <c>U+0001</c> to <c>U+00ff</c>
* in host-native endianness but nothing more;
* in particular, using <c>uriEscapeW</c> with arbitrary Unicode input will
* not produce healthy results.
* Passing UTF-8 input to <c>uriEscapeA</c> may be useful in some scenarios.
* Keep in mind that uriparser is about %URI (RFC 3986) not %IRI (RFC 3987).
*
* @param in <b>IN</b>: Text source
* @param out <b>OUT</b>: Encoded text destination
Expand Down Expand Up @@ -608,6 +626,10 @@ URI_PUBLIC int URI_FUNC(ToStringCharsRequired)(const URI_TYPE(Uri) * uri,
* Converts a %URI structure back to text as described in
* <a href="http://tools.ietf.org/html/rfc3986#section-5.3">section 5.3 of RFC 3986</a>.
*
* NOTE: Scheme-based normalization
* (<a href="http://tools.ietf.org/html/rfc3986#section-6.2.3">section 6.2.3 of RFC 3986</a>)
* is not applied and is considered a responsibility of the application using uriparser.
*
* @param dest <b>OUT</b>: Output destination
* @param uri <b>IN</b>: %URI to convert
* @param maxChars <b>IN</b>: Maximum number of characters to copy <b>including</b> terminator
Expand Down
2 changes: 1 addition & 1 deletion components/playlist/xspf/uriparser/UriBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
/* Version */
#define URI_VER_MAJOR 0
#define URI_VER_MINOR 9
#define URI_VER_RELEASE 7
#define URI_VER_RELEASE 8
#define URI_VER_SUFFIX_ANSI ""
#define URI_VER_SUFFIX_UNICODE URI_ANSI_TO_UNICODE(URI_VER_SUFFIX_ANSI)

Expand Down
2 changes: 1 addition & 1 deletion components/playlist/xspf/uriparser/UriConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@



#define PACKAGE_VERSION "0.9.7"
#define PACKAGE_VERSION "0.9.8"

#undef HAVE_WPRINTF
#undef HAVE_REALLOCARRAY
Expand Down
16 changes: 10 additions & 6 deletions components/playlist/xspf/uriparser/UriQuery.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@


#include <limits.h>
#include <stddef.h> /* size_t */



Expand Down Expand Up @@ -177,10 +178,13 @@ int URI_FUNC(ComposeQueryMallocExMm)(URI_CHAR ** dest,
if (res != URI_SUCCESS) {
return res;
}
if (charsRequired == INT_MAX) {
return URI_ERROR_MALLOC;
}
charsRequired++;

/* Allocate space */
queryString = memory->malloc(memory, charsRequired * sizeof(URI_CHAR));
queryString = memory->calloc(memory, charsRequired, sizeof(URI_CHAR));
if (queryString == NULL) {
return URI_ERROR_MALLOC;
}
Expand Down Expand Up @@ -218,16 +222,16 @@ int URI_FUNC(ComposeQueryEngine)(URI_CHAR * dest,
const URI_CHAR * const key = queryList->key;
const URI_CHAR * const value = queryList->value;
const int worstCase = (normalizeBreaks == URI_TRUE ? 6 : 3);
const int keyLen = (key == NULL) ? 0 : (int)URI_STRLEN(key);
const size_t keyLen = (key == NULL) ? 0 : URI_STRLEN(key);
int keyRequiredChars;
const int valueLen = (value == NULL) ? 0 : (int)URI_STRLEN(value);
const size_t valueLen = (value == NULL) ? 0 : URI_STRLEN(value);
int valueRequiredChars;

if ((keyLen >= INT_MAX / worstCase) || (valueLen >= INT_MAX / worstCase)) {
if ((keyLen >= (size_t)INT_MAX / worstCase) || (valueLen >= (size_t)INT_MAX / worstCase)) {
return URI_ERROR_OUTPUT_TOO_LARGE;
}
keyRequiredChars = worstCase * keyLen;
valueRequiredChars = worstCase * valueLen;
keyRequiredChars = worstCase * (int)keyLen;
valueRequiredChars = worstCase * (int)valueLen;

if (dest == NULL) {
(*charsRequired) += ampersandLen + keyRequiredChars + ((value == NULL)
Expand Down

0 comments on commit 3676eb2

Please sign in to comment.