fix mime-type matching (#7882)

This commit is contained in:
Christian Grothoff 2023-07-05 18:18:23 +02:00
parent 1db17d43bd
commit 40dfb94e0f
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
2 changed files with 9 additions and 4 deletions

View File

@ -126,10 +126,14 @@ mime_matches (const char *accept_pattern,
{ {
const char *da = strchr (accept_pattern, '/'); const char *da = strchr (accept_pattern, '/');
const char *dm = strchr (mime, '/'); const char *dm = strchr (mime, '/');
const char *end;
if ( (NULL == da) || if ( (NULL == da) ||
(NULL == dm) ) (NULL == dm) )
return (0 == strcmp ("*", accept_pattern)); return (0 == strcmp ("*", accept_pattern));
end = strchr (da, ';');
if (NULL == end)
end = &da[strlen (da)];
return return
( ( (1 == da - accept_pattern) && ( ( (1 == da - accept_pattern) &&
('*' == *accept_pattern) ) || ('*' == *accept_pattern) ) ||
@ -138,8 +142,9 @@ mime_matches (const char *accept_pattern,
mime, mime,
da - accept_pattern)) ) ) && da - accept_pattern)) ) ) &&
( (0 == strcmp (da, "/*")) || ( (0 == strcmp (da, "/*")) ||
(0 == strcasecmp (da, (0 == strncasecmp (da,
dm)) ); dm,
end - da)) );
} }
@ -150,7 +155,7 @@ TALER_MHD_xmime_matches (const char *accept_pattern,
char *ap = GNUNET_strdup (accept_pattern); char *ap = GNUNET_strdup (accept_pattern);
char *sptr; char *sptr;
for (const char *tok = strtok_r (ap, ";", &sptr); for (const char *tok = strtok_r (ap, ",", &sptr);
NULL != tok; NULL != tok;
tok = strtok_r (NULL, ";", &sptr)) tok = strtok_r (NULL, ";", &sptr))
{ {

View File

@ -21,7 +21,7 @@ CONFIG = "postgres:///talercheck"
HTTP_PORT = 8082 HTTP_PORT = 8082
[exchange] [exchange]
TERMS_ETAG = 0 TERMS_ETAG = tos
PRIVACY_ETAG = 0 PRIVACY_ETAG = 0
AML_THRESHOLD = EUR:1000000 AML_THRESHOLD = EUR:1000000
PORT = 8081 PORT = 8081