-rw-r--r-- | cgit.c | 3 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgitrc.5.txt | 4 | ||||
-rw-r--r-- | ui-tree.c | 6 |
4 files changed, 14 insertions, 0 deletions
@@ -167,2 +167,4 @@ void config_cb(const char *name, const char *value) ctx.cfg.max_repodesc_len = atoi(value); + else if (!strcmp(name, "max-blob-size")) + ctx.cfg.max_blob_size = atoi(value); else if (!strcmp(name, "max-repo-count")) @@ -272,2 +274,3 @@ static void prepare_context(struct cgit_context *ctx) ctx->cfg.max_repodesc_len = 80; + ctx->cfg.max_blob_size = 0; ctx->cfg.max_stats = 0; @@ -187,2 +187,3 @@ struct cgit_config { int max_repodesc_len; + int max_blob_size; int max_stats; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 0c13485..e69140b 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -179,2 +179,6 @@ max-repodesc-length:: +max-blob-size:: + Specifies the maximum size of a blob to display HTML for in KBytes. + Default value: "0" (limit disabled). + max-stats:: @@ -109,2 +109,8 @@ static void print_object(const unsigned char *sha1, char *path, const char *base + if (ctx.cfg.max_blob_size && size / 1024 > ctx.cfg.max_blob_size) { + htmlf("<div class='error'>blob size (%dKB) exceeds display size limit (%dKB).</div>", + size / 1024, ctx.cfg.max_blob_size); + return; + } + if (buffer_is_binary(buf, size)) |