commit bba9ba6f0ec01a71ac15ac9c6b85fe1d9c500f99
parent fed7d0e782ea4d36b2d2e337d93bfd2723c6ed64
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Fri, 10 Jul 2026 09:02:36 +0200
expose char set
Diffstat:
2 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/src/include/taler/taler_util.h b/src/include/taler/taler_util.h
@@ -439,6 +439,25 @@ TALER_is_web_url (const char *url);
/**
+ * Check if a character is reserved and should be urlencoded.
+ *
+ * Unreserved characters:
+ * - ASCII letters: a-z A-Z
+ * - Digits: 0-9
+ * - Hyphen: -
+ * - Underscore: _
+ * - Period: .
+ * - Tilde: ~
+ *
+ * @param c character to look at
+ * @return true if @a c needs to be urlencoded,
+ * false otherwise (@a c in [a-zA-Z0-9_~.-])
+ */
+bool
+TALER_url_is_reserved (char c);
+
+
+/**
* Test if the URL is a valid slug (URL-safe string).
*
* Allowed characters:
diff --git a/src/util/url.c b/src/util/url.c
@@ -21,16 +21,8 @@
#include "taler/taler_util.h"
-/**
- * Check if a character is reserved and should
- * be urlencoded.
- *
- * @param c character to look at
- * @return true if @a c needs to be urlencoded,
- * false otherwise
- */
-static bool
-is_reserved (char c)
+bool
+TALER_url_is_reserved (char c)
{
switch (c)
{
@@ -67,7 +59,7 @@ urlencode_len (const char *s)
{
size_t len = 0;
for (; *s != '\0'; len++, s++)
- if (is_reserved (*s))
+ if (TALER_url_is_reserved (*s))
len += 2;
return len;
}
@@ -91,7 +83,7 @@ buffer_write_urlencode (struct GNUNET_Buffer *buf,
ulen + 1);
for (size_t i = 0; i < strlen (s); i++)
{
- if (GNUNET_YES == is_reserved (s[i]))
+ if (TALER_url_is_reserved (s[i]))
GNUNET_buffer_write_fstr (buf,
"%%%02X",
(unsigned char) s[i]);