- ctx.page.mimetype = NULL;
- ext = strrchr(path, '.');
- if (ext && *(++ext)) {
- mime = string_list_lookup(ext, &ctx.cfg.mimetypes);
- if (mime)
- ctx.page.mimetype = (char *)mime->util;
+
+ mimetype = get_mimetype_for_filename(path);
+ ctx.page.mimetype = mimetype;
+
+ if (!ctx.repo->enable_html_serving) {
+ html("X-Content-Type-Options: nosniff\n");
+ html("Content-Security-Policy: default-src 'none'\n");
+ if (mimetype) {
+ /* Built-in white list allows PDF and everything that isn't text/ and application/ */
+ if ((!strncmp(mimetype, "text/", 5) || !strncmp(mimetype, "application/", 12)) && strcmp(mimetype, "application/pdf"))
+ ctx.page.mimetype = NULL;
+ }