exchange

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

commit f99ec17b49f472cacb940f189b59d1cccda858f4
parent 4fe3e8b23bfccd0d0d1efdd8513059470bc4977d
Author: Florian Dold <dold@taler.net>
Date:   Tue, 28 Jul 2026 19:16:31 +0200

mhd: rank legal document formats when the client has no preference

The list of terms is sorted best-format-first, but the selection loop
overwrote its candidate on every tie, so the last entry won and /terms
answered with the PDF instead of the plain-text rendering.

Issue: https://bugs.taler.net/n/11635

Diffstat:
Msrc/mhd/mhd2_legal.c | 13+++++++++++--
Msrc/mhd/mhd_legal.c | 13+++++++++++--
2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/src/mhd/mhd2_legal.c b/src/mhd/mhd2_legal.c @@ -228,8 +228,17 @@ TALER_MHD2_reply_legal (struct MHD_Request *request, } q = TALER_pattern_matches (lang, p->language); - if (q < best_lang_q) - continue; + if (NULL != t) + { + if (q < best_lang_q) + continue; + /* Client expressed no preference between these two formats, + so fall back to our own ranking instead of letting the + last entry in the list win. */ + if ( (q == best_lang_q) && + (p->priority <= t->priority) ) + continue; + } best_lang_q = q; t = p; } diff --git a/src/mhd/mhd_legal.c b/src/mhd/mhd_legal.c @@ -220,8 +220,17 @@ TALER_MHD_reply_legal (struct MHD_Connection *conn, p->language); GNUNET_free (tmp); } - if (q < best_lang_q) - continue; + if (NULL != t) + { + if (q < best_lang_q) + continue; + /* Client expressed no preference between these two formats, + so fall back to our own ranking instead of letting the + last entry in the list win. */ + if ( (q == best_lang_q) && + (p->priority <= t->priority) ) + continue; + } best_lang_q = q; t = p; }