mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-16 10:39:49 +00:00
Fix #2871 - accept * in mg_http_serve_opts::mime_types
This commit is contained in:
1 parent
44b3d60692
commit
eeecbbcff9
3 files changed
+27
-8
No files matched your search
+5
-3
@@ -1,7 +1,7 @@
|
||||
#include "http.h"
|
||||
#include "arch.h"
|
||||
#include "base64.h"
|
||||
#include "fmt.h"
|
||||
#include "http.h"
|
||||
#include "json.h"
|
||||
#include "log.h"
|
||||
#include "net.h"
|
||||
@@ -521,7 +521,7 @@ static struct mg_str s_known_types[] = {
|
||||
// clang-format on
|
||||
|
||||
static struct mg_str guess_content_type(struct mg_str path, const char *extra) {
|
||||
struct mg_str entry, k, v, s = mg_str(extra);
|
||||
struct mg_str entry, k, v, s = mg_str(extra), asterisk = mg_str_n("*", 1);
|
||||
size_t i = 0;
|
||||
|
||||
// Shrink path to its extension only
|
||||
@@ -531,7 +531,9 @@ static struct mg_str guess_content_type(struct mg_str path, const char *extra) {
|
||||
|
||||
// Process user-provided mime type overrides, if any
|
||||
while (mg_span(s, &entry, &s, ',')) {
|
||||
if (mg_span(entry, &k, &v, '=') && mg_strcmp(path, k) == 0) return v;
|
||||
if (mg_span(entry, &k, &v, '=') &&
|
||||
(mg_strcmp(asterisk, k) == 0 || mg_strcmp(path, k) == 0))
|
||||
return v;
|
||||
}
|
||||
|
||||
// Process built-in mime types
|
||||
|
||||
Reference in new issue
Block a user