summaryrefslogtreecommitdiffstats
path: root/contrib/libs/curl/lib/urlapi.c
diff options
context:
space:
mode:
authorrobot-contrib <[email protected]>2022-07-12 12:03:53 +0300
committerrobot-contrib <[email protected]>2022-07-12 12:03:53 +0300
commiteeebfbedb3ea4cab5c0aac178b683b7dd26b0bf6 (patch)
tree4783d362be8e22467d0f5eb581ce6f65e33acb04 /contrib/libs/curl/lib/urlapi.c
parent4213b519b93b5e3d657bc362837adfea82579dcc (diff)
Update contrib/libs/curl to 7.84.0
Diffstat (limited to 'contrib/libs/curl/lib/urlapi.c')
-rw-r--r--contrib/libs/curl/lib/urlapi.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/contrib/libs/curl/lib/urlapi.c b/contrib/libs/curl/lib/urlapi.c
index 2a36de6a58f..dee4b5aa098 100644
--- a/contrib/libs/curl/lib/urlapi.c
+++ b/contrib/libs/curl/lib/urlapi.c
@@ -18,6 +18,8 @@
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
+ * SPDX-License-Identifier: curl
+ *
***************************************************************************/
#include "curl_setup.h"
@@ -175,14 +177,17 @@ static size_t strlen_url(const char *url, bool relative)
* the source URL accordingly.
* URL encoding should be skipped for host names, otherwise IDN resolution
* will fail.
+ *
+ * Returns TRUE if something was updated.
*/
-static void strcpy_url(char *output, const char *url, bool relative)
+static bool strcpy_url(char *output, const char *url, bool relative)
{
/* we must add this with whitespace-replacing */
bool left = TRUE;
const unsigned char *iptr;
char *optr = output;
const unsigned char *host_sep = (const unsigned char *) url;
+ bool changed = FALSE;
if(!relative)
host_sep = (const unsigned char *) find_host_sep(url);
@@ -204,6 +209,7 @@ static void strcpy_url(char *output, const char *url, bool relative)
}
else
*optr++='+'; /* add a '+' here */
+ changed = TRUE;
continue;
}
@@ -212,6 +218,7 @@ static void strcpy_url(char *output, const char *url, bool relative)
if(urlchar_needs_escaping(*iptr)) {
msnprintf(optr, 4, "%%%02x", *iptr);
+ changed = TRUE;
optr += 3;
}
else
@@ -219,6 +226,7 @@ static void strcpy_url(char *output, const char *url, bool relative)
}
*optr = 0; /* null-terminate output buffer */
+ return changed;
}
/*
@@ -1436,6 +1444,19 @@ CURLUcode curl_url_get(CURLU *u, CURLUPart what,
}
*part = decoded;
}
+ if(urlencode) {
+ /* worst case output length is 3x the original! */
+ char *newp = malloc(strlen(*part) * 3);
+ if(!newp)
+ return CURLUE_OUT_OF_MEMORY;
+ if(strcpy_url(newp, *part, TRUE)) { /* consider it relative */
+ free(*part);
+ *part = newp;
+ }
+ else
+ free(newp);
+ }
+
return CURLUE_OK;
}
else
@@ -1497,6 +1518,10 @@ CURLUcode curl_url_set(CURLU *u, CURLUPart what,
if(storep && *storep) {
Curl_safefree(*storep);
}
+ else if(!storep) {
+ free_urlhandle(u);
+ memset(u, 0, sizeof(struct Curl_URL));
+ }
return CURLUE_OK;
}