[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 06/10: MHD_str_equal_caseless_quoted_bin_n(): added new
From: |
gnunet |
Subject: |
[libmicrohttpd] 06/10: MHD_str_equal_caseless_quoted_bin_n(): added new internal function |
Date: |
Mon, 06 Jun 2022 18:41:32 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit 1a37de9601862a2875629cc6698b17cda4ca534c
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Mon Jun 6 15:53:21 2022 +0300
MHD_str_equal_caseless_quoted_bin_n(): added new internal function
---
src/microhttpd/mhd_str.c | 30 ++++++++++++++++++++++++++++++
src/microhttpd/mhd_str.h | 26 ++++++++++++++++++++++++++
2 files changed, 56 insertions(+)
diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c
index 1732c609..5829daa5 100644
--- a/src/microhttpd/mhd_str.c
+++ b/src/microhttpd/mhd_str.c
@@ -1418,6 +1418,36 @@ MHD_str_equal_quoted_bin_n (const char *quoted,
}
+bool
+MHD_str_equal_caseless_quoted_bin_n (const char *quoted,
+ size_t quoted_len,
+ const char *unquoted,
+ size_t unquoted_len)
+{
+ size_t i;
+ size_t j;
+ if (unquoted_len < quoted_len / 2)
+ return false;
+
+ j = 0;
+ for (i = 0; quoted_len > i && unquoted_len > j; ++i, ++j)
+ {
+ if ('\\' == quoted[i])
+ {
+ i++; /* Advance to the next character */
+ if (quoted_len == i)
+ return false; /* No character after escaping backslash */
+ }
+ if (! charsequalcaseless (quoted[i], unquoted[j]))
+ return false; /* Different characters */
+ }
+ if ((quoted_len != i) || (unquoted_len != j))
+ return false; /* The strings have different length */
+
+ return true;
+}
+
+
size_t
MHD_str_unquote (const char *quoted,
size_t quoted_len,
diff --git a/src/microhttpd/mhd_str.h b/src/microhttpd/mhd_str.h
index a114d9a3..7cf827ab 100644
--- a/src/microhttpd/mhd_str.h
+++ b/src/microhttpd/mhd_str.h
@@ -501,6 +501,32 @@ MHD_str_equal_quoted_bin_n (const char *quoted,
const char *unquoted,
size_t unquoted_len);
+/**
+ * Check two strings for equality, "unquoting" the first string from quoted
+ * form as specified by RFC7230#section-3.2.6 and RFC7694#quoted.strings and
+ * ignoring case of US-ASCII letters.
+ *
+ * Null-termination for input stings is not required, binary zeros compared
+ * like other characters.
+ *
+ * @param quoted the quoted string to compare, must NOT include leading and
+ * closing DQUOTE chars, does not need to be zero-terminated
+ * @param quoted_len the length in chars of the @a quoted string
+ * @param unquoted the unquoted string to compare, does not need to be
+ * zero-terminated
+ * @param unquoted_len the length in chars of the @a unquoted string
+ * @return zero if quoted form is broken (no character after the last escaping
+ * backslash), zero if strings are not equal after unquoting of the
+ * first string,
+ * non-zero if two strings are caseless equal after unquoting of the
+ * first string.
+ */
+bool
+MHD_str_equal_caseless_quoted_bin_n (const char *quoted,
+ size_t quoted_len,
+ const char *unquoted,
+ size_t unquoted_len);
+
/**
* Convert string from quoted to unquoted form as specified by
* RFC7230#section-3.2.6 and RFC7694#quoted.strings.
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] branch master updated (56c4b4ae -> 8d5ebaec), gnunet, 2022/06/06
- [libmicrohttpd] 01/10: test_auth_parse: minor formatting imrpovement, gnunet, 2022/06/06
- [libmicrohttpd] 02/10: mhd_str: fixed doxy again, gnunet, 2022/06/06
- [libmicrohttpd] 03/10: MHD_str_equal_quoted_bin_n(): added new internal function, gnunet, 2022/06/06
- [libmicrohttpd] 04/10: test_str_quote: added new test, gnunet, 2022/06/06
- [libmicrohttpd] 06/10: MHD_str_equal_caseless_quoted_bin_n(): added new internal function,
gnunet <=
- [libmicrohttpd] 09/10: digestauth: avoid repetitive calculations of some strings' length, gnunet, 2022/06/06
- [libmicrohttpd] 08/10: Simplified Digest Auth code by using the new string processing functions, gnunet, 2022/06/06
- [libmicrohttpd] 05/10: Excluded build on the new string functions when they are unused, gnunet, 2022/06/06
- [libmicrohttpd] 10/10: gen_auth: simplified value assignment, gnunet, 2022/06/06
- [libmicrohttpd] 07/10: test_str_quote: added testing of the new function, gnunet, 2022/06/06