[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 03/06: MHD_str_unquote(): added new internal function
From: |
gnunet |
Subject: |
[libmicrohttpd] 03/06: MHD_str_unquote(): added new internal function |
Date: |
Sat, 28 May 2022 18:56:35 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 664d8ca99f681d6f222ec754f3f1d2943b78df7c
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Fri May 20 13:06:57 2022 +0300
MHD_str_unquote(): added new internal function
---
src/microhttpd/mhd_str.c | 25 +++++++++++++++++++++++++
src/microhttpd/mhd_str.h | 19 +++++++++++++++++++
2 files changed, 44 insertions(+)
diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c
index da60b18d..484de105 100644
--- a/src/microhttpd/mhd_str.c
+++ b/src/microhttpd/mhd_str.c
@@ -1375,3 +1375,28 @@ MHD_bin_to_hex (const void *bin,
hex[i * 2] = 0;
return i;
}
+
+
+size_t
+MHD_str_unquote (const char *quoted,
+ size_t quoted_len,
+ char *result)
+{
+ size_t r;
+ size_t w;
+
+ r = 0;
+ w = 0;
+
+ while (quoted_len > r)
+ {
+ if ('\\' == quoted[r])
+ {
+ ++r;
+ if (quoted_len == r)
+ return 0; /* Last backslash is not followed by char to unescape */
+ }
+ result[w++] = quoted[r++];
+ }
+ return w;
+}
diff --git a/src/microhttpd/mhd_str.h b/src/microhttpd/mhd_str.h
index cdf92067..851fabb7 100644
--- a/src/microhttpd/mhd_str.h
+++ b/src/microhttpd/mhd_str.h
@@ -471,4 +471,23 @@ MHD_bin_to_hex (const void *bin,
size_t size,
char *hex);
+/**
+ * Convert string from quoted to unquoted form as specified by
+ * RFC7230#section-3.2.6 and RFC7694#quoted.strings.
+ *
+ * @param quoted the quoted string, must NOT include leading and closing
+ * DQUOTE chars, does not need to be zero-terminated
+ * @param size the size in chars of the @a quited string
+ * @param[out] result the pointer to the buffer to put the result, must
+ * be at least @a size character long. The result is NOT
+ * zero-terminated.
+ * @return The number of characters written to the output buffer,
+ * zero if last backslash is not followed by any character (or
+ * @a size is zero).
+ */
+size_t
+MHD_str_unquote (const char *quoted,
+ size_t quoted_len,
+ char *result);
+
#endif /* MHD_STR_H */
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (b1fff186 -> 435cd008), gnunet, 2022/05/28
- [libmicrohttpd] 04/06: connection_alloc_memory_(): made function non-static, gnunet, 2022/05/28
- [libmicrohttpd] 02/06: Created digestauth.h header, gnunet, 2022/05/28
- [libmicrohttpd] 03/06: MHD_str_unquote(): added new internal function,
gnunet <=
- [libmicrohttpd] 01/06: Created basicauth.h header, gnunet, 2022/05/28
- [libmicrohttpd] 05/06: digestauth: reworked support for multiple digest algorithms, gnunet, 2022/05/28
- [libmicrohttpd] 06/06: test_basicauth: added new test, gnunet, 2022/05/28