commit f194a76d391d9a3c7c0d7a0070759fc1809ad082
parent 40e9f174512ac8582e3c90b6a933996bf28a347f
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Sun, 16 Aug 2026 08:27:31 +0200
require strictly better 'q'
Diffstat:
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/templating/templating_api.c b/src/templating/templating_api.c
@@ -77,6 +77,7 @@ lookup_template (struct MHD_Connection *connection,
const char *name)
{
struct TVE *best = NULL;
+ struct TVE *fallback = NULL;
double best_q = 0.0;
const char *lang;
@@ -95,14 +96,18 @@ lookup_template (struct MHD_Connection *connection,
continue; /* does not match by name */
if (NULL == loaded[i].lang) /* no language == always best match */
return &loaded[i];
+ if (NULL == fallback)
+ fallback = &loaded[i]; /* in case nothing matches the language */
q = TALER_pattern_matches (lang,
loaded[i].lang);
- if (q < best_q)
- continue;
+ if (q <= best_q)
+ continue; /* not a strictly better match than what we have */
best_q = q;
best = &loaded[i];
}
if (NULL == best)
+ best = fallback; /* no variant matched the language, serve any */
+ if (NULL == best)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"No templates found for `%s'\n",