diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-04-23 16:06:21 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-04-23 16:06:21 +0200 |
commit | de61e06eb164c5cb05778aba8e448a001462b783 (patch) | |
tree | db96805eeef172c88444c7aece02cc89830dacb3 /src | |
parent | 8b99abbe62464d336fa8e5ab662aaf4bc1c72b2e (diff) |
fix #6198
Diffstat (limited to 'src')
-rw-r--r-- | src/mhd/mhd_legal.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/mhd/mhd_legal.c b/src/mhd/mhd_legal.c index b7859da1c..a46b7279d 100644 --- a/src/mhd/mhd_legal.c +++ b/src/mhd/mhd_legal.c @@ -110,6 +110,7 @@ mime_matches (const char *accept_pattern, /** * Check if @a lang matches the @a language_pattern, and if so with * which preference. + * See also: https://tools.ietf.org/html/rfc7231#section-5.3.1 * * @param language_pattern a language preferences string * like "fr-CH, fr;q=0.9, en;q=0.8, *;q=0.1" @@ -125,15 +126,20 @@ language_matches (const char *language_pattern, char *sptr; double r = 0.0; - for (char *tok = strtok_r (p, ", ", &sptr); + for (char *tok = strtok_r (p, ",", &sptr); NULL != tok; - tok = strtok_r (NULL, ", ", &sptr)) + tok = strtok_r (NULL, ",", &sptr)) { char *sptr2; char *lp = strtok_r (tok, ";", &sptr2); char *qp = strtok_r (NULL, ";", &sptr2); double q = 1.0; + while (isspace ((int) *lp)) + lp++; + if (NULL != qp) + while (isspace ((int) *qp)) + qp++; GNUNET_break_op ( (NULL == qp) || (1 == sscanf (qp, "q=%lf", |