From 242dd674162b790b836b04597edcf2a8858a873d Mon Sep 17 00:00:00 2001 From: simon987 Date: Sat, 1 Jul 2023 09:06:03 -0400 Subject: [PATCH] Fix #378 --- src/web/serve.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/web/serve.c b/src/web/serve.c index f31ee68..f50b00c 100644 --- a/src/web/serve.c +++ b/src/web/serve.c @@ -248,9 +248,11 @@ void serve_file_from_disk(cJSON *json, index_t *idx, struct mg_connection *nc, s char mime_mapping[8192]; if (strlen(ext) == 0) { - snprintf(mime_mapping, sizeof(mime_mapping), "%s=%s", full_path, mime); + snprintf(mime_mapping, sizeof(mime_mapping), "%s=%s%s", + full_path, mime, STR_STARTS_WITH_CONSTANT(mime, "text/") ? "; charset=utf8" : ""); } else { - snprintf(mime_mapping, sizeof(mime_mapping), "%s=%s", ext, mime); + snprintf(mime_mapping, sizeof(mime_mapping), "%s=%s%s", + ext, mime, STR_STARTS_WITH_CONSTANT(mime, "text/") ? "; charset=utf8" : ""); } struct mg_http_serve_opts opts = {