X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/08a2b818f2bd3221a1685c28c62408d57b0993a7..c326f3eb026d67650f79a6dda9a1a42c55d10a25:/ui-plain.c diff --git a/ui-plain.c b/ui-plain.c index e4beb99..ff85113 100644 --- a/ui-plain.c +++ b/ui-plain.c @@ -37,6 +37,16 @@ static int print_object(const unsigned char *sha1, const char *path) 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; + } + } + if (!ctx.page.mimetype) { if (buffer_is_binary(buf, size)) { ctx.page.mimetype = "application/octet-stream"; @@ -183,7 +193,7 @@ void cgit_print_plain(void) if (!path_items.match) { path_items.match = ""; walk_tree_ctx.match_baselen = -1; - print_dir(commit->tree->object.sha1, "", 0, ""); + print_dir(commit->tree->object.oid.hash, "", 0, ""); walk_tree_ctx.match = 2; } else