exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

commit 67e4c8b94aa7198cc6a98eb4cf67ef0d02222b20
parent 607ba0aec449eb3a04236330c5244df057922b76
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 10 Oct 2026 22:42:42 +0200

fix language check

Diffstat:
Msrc/mhd/mhd_legal.c | 38+++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/src/mhd/mhd_legal.c b/src/mhd/mhd_legal.c @@ -121,6 +121,42 @@ struct TALER_MHD_Legal }; +/** + * Check if the comma-separated list @a langs already contains + * the entry @a lang. + * + * @param langs comma-separated list of languages + * @param lang language to look for + * @return true if @a lang is an entry of @a langs + */ +static bool +lang_in_list (const char *langs, + const char *lang) +{ + size_t len = strlen (lang); + const char *pos = langs; + + while (NULL != pos) + { + const char *end = strchr (pos, + ','); + size_t elen = (NULL == end) + ? strlen (pos) + : (size_t) (end - pos); + + if ( (elen == len) && + (0 == strncasecmp (pos, + lang, + len)) ) + return true; + pos = (NULL == end) + ? NULL + : end + 1; + } + return false; +} + + enum MHD_Result TALER_MHD_reply_legal (struct MHD_Connection *conn, struct TALER_MHD_Legal *legal) @@ -209,7 +245,7 @@ TALER_MHD_reply_legal (struct MHD_Connection *conn, { langs = GNUNET_strdup (p->language); } - else if (NULL == strstr (langs, + else if (! lang_in_list (langs, p->language)) { char *tmp = langs;