diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-08-02 19:48:37 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-08-02 19:48:37 +0200 |
commit | 3a6ae694ecba19af06d84906facbcb5f7d51d72b (patch) | |
tree | 8f7c57fa0233300407436b6779c1c4b468d1bf01 | |
parent | 2ce37548c0b204eace2661992b23214cfd0e0b4b (diff) | |
download | exchange-3a6ae694ecba19af06d84906facbcb5f7d51d72b.tar.gz exchange-3a6ae694ecba19af06d84906facbcb5f7d51d72b.zip |
-work on #6948
-rw-r--r-- | src/include/taler_util.h | 9 | ||||
-rw-r--r-- | src/util/url.c | 16 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/include/taler_util.h b/src/include/taler_util.h index 33c126cbc..59824a521 100644 --- a/src/include/taler_util.h +++ b/src/include/taler_util.h | |||
@@ -183,6 +183,15 @@ TALER_project_data_default (void); | |||
183 | char * | 183 | char * |
184 | TALER_urlencode (const char *s); | 184 | TALER_urlencode (const char *s); |
185 | 185 | ||
186 | /** | ||
187 | * Test if all characters in @a url are valid for | ||
188 | * a URL. | ||
189 | * | ||
190 | * @param url URL to sanity-check | ||
191 | * @return true if @a url only contains valid characters | ||
192 | */ | ||
193 | bool | ||
194 | TALER_url_valid_charset (const char *url); | ||
186 | 195 | ||
187 | /** | 196 | /** |
188 | * Check if @a lang matches the @a language_pattern, and if so with | 197 | * Check if @a lang matches the @a language_pattern, and if so with |
diff --git a/src/util/url.c b/src/util/url.c index 5962a18b2..3fbc4a048 100644 --- a/src/util/url.c +++ b/src/util/url.c | |||
@@ -365,4 +365,20 @@ TALER_url_absolute_raw (const char *proto, | |||
365 | } | 365 | } |
366 | 366 | ||
367 | 367 | ||
368 | bool | ||
369 | TALER_url_valid_charset (const char *url) | ||
370 | { | ||
371 | for (unsigned int i = 0; '\0' != url[i]; i++) | ||
372 | { | ||
373 | #define ALLOWED_CHARACTERS \ | ||
374 | "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/:&?-.,=_~%" | ||
375 | if (NULL == strchr (ALLOWED_CHARACTERS, | ||
376 | (int) url[i])) | ||
377 | return false; | ||
378 | #undef ALLOWED_CHARACTERS | ||
379 | } | ||
380 | return true; | ||
381 | } | ||
382 | |||
383 | |||
368 | /* end of url.c */ | 384 | /* end of url.c */ |