From 9e46b8ea25932906fb88ae54fb19650711598021 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Sat, 15 Apr 2017 12:44:11 -0400 Subject: [PATCH] [core] extend mimetype search w/o leading '.' repeat extension search without leading '.' to handle situation where admin configured mimetype.assign keys without leading '.' --- src/stat_cache.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/stat_cache.c b/src/stat_cache.c index 7215fdf9..732e3cf3 100644 --- a/src/stat_cache.c +++ b/src/stat_cache.c @@ -296,9 +296,21 @@ const buffer * stat_cache_mimetype_by_ext(const connection *con, const char *nam if (NULL != ds) return ds->value; while (++s < end) { while (*s != '.' && ++s != end) ; + if (s == end) break; + /* search ".ext" then "ext" */ ds = (data_string *)array_get_element(con->conf.mimetypes, s); if (NULL != ds) return ds->value; + /* repeat search without leading '.' to handle situation where + * admin configured mimetype.assign keys without leading '.' */ + if (++s < end) { + if (*s == '.') { --s; continue; } + ds = (data_string *)array_get_element(con->conf.mimetypes, s); + if (NULL != ds) return ds->value; + } } + /* search for ""; catchall */ + ds = (data_string *)array_get_element(con->conf.mimetypes, ""); + if (NULL != ds) return ds->value; } return NULL;