summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2017-04-15 12:44:11 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2017-04-15 12:44:11 -0400
commit9e46b8ea25932906fb88ae54fb19650711598021 (patch)
tree51b59abc3d98e01c2ff4fd73b9a8ca7ab557bda5
parenta434a3fab04e521c4ca5d2593a0a08f4b5a87c15 (diff)
downloadlighttpd1.4-9e46b8ea25932906fb88ae54fb19650711598021.tar.gz
lighttpd1.4-9e46b8ea25932906fb88ae54fb19650711598021.zip
[core] extend mimetype search w/o leading '.'
repeat extension search without leading '.' to handle situation where admin configured mimetype.assign keys without leading '.'
-rw-r--r--src/stat_cache.c12
1 files changed, 12 insertions, 0 deletions
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;