This commit is contained in:
Christian Grothoff 2021-08-02 19:48:37 +02:00
parent 2ce37548c0
commit 3a6ae694ec
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 25 additions and 0 deletions

View File

@ -183,6 +183,15 @@ TALER_project_data_default (void);
char *
TALER_urlencode (const char *s);
/**
* Test if all characters in @a url are valid for
* a URL.
*
* @param url URL to sanity-check
* @return true if @a url only contains valid characters
*/
bool
TALER_url_valid_charset (const char *url);
/**
* Check if @a lang matches the @a language_pattern, and if so with

View File

@ -365,4 +365,20 @@ TALER_url_absolute_raw (const char *proto,
}
bool
TALER_url_valid_charset (const char *url)
{
for (unsigned int i = 0; '\0' != url[i]; i++)
{
#define ALLOWED_CHARACTERS \
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/:&?-.,=_~%"
if (NULL == strchr (ALLOWED_CHARACTERS,
(int) url[i]))
return false;
#undef ALLOWED_CHARACTERS
}
return true;
}
/* end of url.c */