diff options
-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
@@ -165,6 +165,8 @@ void config_cb(const char *name, const char *value) | |||
165 | ctx.cfg.max_msg_len = atoi(value); | 165 | ctx.cfg.max_msg_len = atoi(value); |
166 | else if (!strcmp(name, "max-repodesc-length")) | 166 | else if (!strcmp(name, "max-repodesc-length")) |
167 | ctx.cfg.max_repodesc_len = atoi(value); | 167 | ctx.cfg.max_repodesc_len = atoi(value); |
168 | else if (!strcmp(name, "max-blob-size")) | ||
169 | ctx.cfg.max_blob_size = atoi(value); | ||
168 | else if (!strcmp(name, "max-repo-count")) | 170 | else if (!strcmp(name, "max-repo-count")) |
169 | ctx.cfg.max_repo_count = atoi(value); | 171 | ctx.cfg.max_repo_count = atoi(value); |
170 | else if (!strcmp(name, "max-commit-count")) | 172 | else if (!strcmp(name, "max-commit-count")) |
@@ -270,6 +272,7 @@ static void prepare_context(struct cgit_context *ctx) | |||
270 | ctx->cfg.max_lock_attempts = 5; | 272 | ctx->cfg.max_lock_attempts = 5; |
271 | ctx->cfg.max_msg_len = 80; | 273 | ctx->cfg.max_msg_len = 80; |
272 | ctx->cfg.max_repodesc_len = 80; | 274 | ctx->cfg.max_repodesc_len = 80; |
275 | ctx->cfg.max_blob_size = 0; | ||
273 | ctx->cfg.max_stats = 0; | 276 | ctx->cfg.max_stats = 0; |
274 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; | 277 | ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s"; |
275 | ctx->cfg.renamelimit = -1; | 278 | ctx->cfg.renamelimit = -1; |
@@ -185,6 +185,7 @@ struct cgit_config { | |||
185 | int max_lock_attempts; | 185 | int max_lock_attempts; |
186 | int max_msg_len; | 186 | int max_msg_len; |
187 | int max_repodesc_len; | 187 | int max_repodesc_len; |
188 | int max_blob_size; | ||
188 | int max_stats; | 189 | int max_stats; |
189 | int nocache; | 190 | int nocache; |
190 | int noplainemail; | 191 | int noplainemail; |
diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 0c13485..e69140b 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt | |||
@@ -177,6 +177,10 @@ max-repodesc-length:: | |||
177 | Specifies the maximum number of repo description characters to display | 177 | Specifies the maximum number of repo description characters to display |
178 | on the repository index page. Default value: "80". | 178 | on the repository index page. Default value: "80". |
179 | 179 | ||
180 | max-blob-size:: | ||
181 | Specifies the maximum size of a blob to display HTML for in KBytes. | ||
182 | Default value: "0" (limit disabled). | ||
183 | |||
180 | max-stats:: | 184 | max-stats:: |
181 | Set the default maximum statistics period. Valid values are "week", | 185 | Set the default maximum statistics period. Valid values are "week", |
182 | "month", "quarter" and "year". If unspecified, statistics are | 186 | "month", "quarter" and "year". If unspecified, statistics are |
@@ -107,6 +107,12 @@ static void print_object(const unsigned char *sha1, char *path, const char *base | |||
107 | curr_rev, path); | 107 | curr_rev, path); |
108 | htmlf(")<br/>blob: %s\n", sha1_to_hex(sha1)); | 108 | htmlf(")<br/>blob: %s\n", sha1_to_hex(sha1)); |
109 | 109 | ||
110 | if (ctx.cfg.max_blob_size && size / 1024 > ctx.cfg.max_blob_size) { | ||
111 | htmlf("<div class='error'>blob size (%dKB) exceeds display size limit (%dKB).</div>", | ||
112 | size / 1024, ctx.cfg.max_blob_size); | ||
113 | return; | ||
114 | } | ||
115 | |||
110 | if (buffer_is_binary(buf, size)) | 116 | if (buffer_is_binary(buf, size)) |
111 | print_binary_buffer(buf, size); | 117 | print_binary_buffer(buf, size); |
112 | else | 118 | else |