diff options
author | dartraiden <wowemuh@gmail.com> | 2023-10-11 18:36:33 +0300 |
---|---|---|
committer | dartraiden <wowemuh@gmail.com> | 2023-10-11 18:38:34 +0300 |
commit | b7dfc6fda6f6b461f45a2ce457911bf128160208 (patch) | |
tree | 795d58d5d6d83c483022c3e14640f5999d0c0623 /libs/libcurl/src/escape.c | |
parent | f40b2ce583f05b0756c4552f2e46535bea2c0c39 (diff) |
libcurl: update to 8.4.0
Diffstat (limited to 'libs/libcurl/src/escape.c')
-rw-r--r-- | libs/libcurl/src/escape.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/libs/libcurl/src/escape.c b/libs/libcurl/src/escape.c index de706797a2..a64137c8ae 100644 --- a/libs/libcurl/src/escape.c +++ b/libs/libcurl/src/escape.c @@ -38,33 +38,6 @@ #include "curl_memory.h"
#include "memdebug.h"
-/* Portable character check (remember EBCDIC). Do not use isalnum() because
- its behavior is altered by the current locale.
- See https://datatracker.ietf.org/doc/html/rfc3986#section-2.3
-*/
-bool Curl_isunreserved(unsigned char in)
-{
- switch(in) {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- case 'a': case 'b': case 'c': case 'd': case 'e':
- case 'f': case 'g': case 'h': case 'i': case 'j':
- case 'k': case 'l': case 'm': case 'n': case 'o':
- case 'p': case 'q': case 'r': case 's': case 't':
- case 'u': case 'v': case 'w': case 'x': case 'y': case 'z':
- case 'A': case 'B': case 'C': case 'D': case 'E':
- case 'F': case 'G': case 'H': case 'I': case 'J':
- case 'K': case 'L': case 'M': case 'N': case 'O':
- case 'P': case 'Q': case 'R': case 'S': case 'T':
- case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z':
- case '-': case '.': case '_': case '~':
- return TRUE;
- default:
- break;
- }
- return FALSE;
-}
-
/* for ABI-compatibility with previous versions */
char *curl_escape(const char *string, int inlength)
{
@@ -99,7 +72,7 @@ char *curl_easy_escape(struct Curl_easy *data, const char *string, while(length--) {
unsigned char in = *string++; /* treat the characters unsigned */
- if(Curl_isunreserved(in)) {
+ if(ISUNRESERVED(in)) {
/* append this */
if(Curl_dyn_addn(&d, &in, 1))
return NULL;
@@ -233,3 +206,29 @@ void curl_free(void *p) {
free(p);
}
+
+/*
+ * Curl_hexencode()
+ *
+ * Converts binary input to lowercase hex-encoded ASCII output.
+ * Null-terminated.
+ */
+void Curl_hexencode(const unsigned char *src, size_t len, /* input length */
+ unsigned char *out, size_t olen) /* output buffer size */
+{
+ const char *hex = "0123456789abcdef";
+ DEBUGASSERT(src && len && (olen >= 3));
+ if(src && len && (olen >= 3)) {
+ while(len-- && (olen >= 3)) {
+ /* clang-tidy warns on this line without this comment: */
+ /* NOLINTNEXTLINE(clang-analyzer-core.UndefinedBinaryOperatorResult) */
+ *out++ = hex[(*src & 0xF0)>>4];
+ *out++ = hex[*src & 0x0F];
+ ++src;
+ olen -= 2;
+ }
+ *out = 0;
+ }
+ else if(olen)
+ *out = 0;
+}
|