diff options
author | Daniel Stenberg <daniel@haxx.se> | 2018-08-05 11:51:07 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2018-09-08 15:36:11 +0200 |
commit | fb30ac5a2d63773c529c19259754e2b306ac2e2e (patch) | |
tree | 0e26d4e3f085a2f50b19f3eba53bafce509e3826 /lib/escape.c | |
parent | 17ca0ccff4aeacc63bf7fa90314ea58d23464617 (diff) | |
download | curl-fb30ac5a2d63773c529c19259754e2b306ac2e2e.tar.gz |
URL-API
See header file and man pages for API. All documented API details work
and are tested in the 1560 test case.
Closes #2842
Diffstat (limited to 'lib/escape.c')
-rw-r--r-- | lib/escape.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/escape.c b/lib/escape.c index 10774f058..afd3899f9 100644 --- a/lib/escape.c +++ b/lib/escape.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -41,7 +41,7 @@ its behavior is altered by the current locale. See https://tools.ietf.org/html/rfc3986#section-2.3 */ -static bool Curl_isunreserved(unsigned char in) +bool Curl_isunreserved(unsigned char in) { switch(in) { case '0': case '1': case '2': case '3': case '4': @@ -141,6 +141,8 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string, * Returns a pointer to a malloced string in *ostring with length given in * *olen. If length == 0, the length is assumed to be strlen(string). * + * 'data' can be set to NULL but then this function can't convert network + * data to host for non-ascii. */ CURLcode Curl_urldecode(struct Curl_easy *data, const char *string, size_t length, @@ -151,7 +153,7 @@ CURLcode Curl_urldecode(struct Curl_easy *data, char *ns = malloc(alloc); size_t strindex = 0; unsigned long hex; - CURLcode result; + CURLcode result = CURLE_OK; if(!ns) return CURLE_OUT_OF_MEMORY; @@ -171,11 +173,13 @@ CURLcode Curl_urldecode(struct Curl_easy *data, in = curlx_ultouc(hex); /* this long is never bigger than 255 anyway */ - result = Curl_convert_from_network(data, (char *)&in, 1); - if(result) { - /* Curl_convert_from_network calls failf if unsuccessful */ - free(ns); - return result; + if(data) { + result = Curl_convert_from_network(data, (char *)&in, 1); + if(result) { + /* Curl_convert_from_network calls failf if unsuccessful */ + free(ns); + return result; + } } string += 2; |