about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--cgit.c3
-rw-r--r--cgit.h1
-rw-r--r--cgitrc.5.txt4
-rw-r--r--ui-tree.c6
4 files changed, 14 insertions, 0 deletions
diff --git a/cgit.c b/cgit.c
index a17f40d..e1d38c2 100644
--- a/cgit.c
+++ b/cgit.c
@@ -165,6 +165,8 @@ void config_cb(const char *name, const char *value)
 		ctx.cfg.max_msg_len = atoi(value);
 	else if (!strcmp(name, "max-repodesc-length"))
 		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"))
 		ctx.cfg.max_repo_count = atoi(value);
 	else if (!strcmp(name, "max-commit-count"))
@@ -270,6 +272,7 @@ static void prepare_context(struct cgit_context *ctx)
 	ctx->cfg.max_lock_attempts = 5;
 	ctx->cfg.max_msg_len = 80;
 	ctx->cfg.max_repodesc_len = 80;
+	ctx->cfg.max_blob_size = 0;
 	ctx->cfg.max_stats = 0;
 	ctx->cfg.module_link = "./?repo=%s&page=commit&id=%s";
 	ctx->cfg.renamelimit = -1;
diff --git a/cgit.h b/cgit.h
index 6c6c460..39853df 100644
--- a/cgit.h
+++ b/cgit.h
@@ -185,6 +185,7 @@ struct cgit_config {
 	int max_lock_attempts;
 	int max_msg_len;
 	int max_repodesc_len;
+	int max_blob_size;
 	int max_stats;
 	int nocache;
 	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::
 	Specifies the maximum number of repo description characters to display
 	on the repository index page. Default value: "80".
 
+max-blob-size::
+	Specifies the maximum size of a blob to display HTML for in KBytes.
+	Default value: "0" (limit disabled).
+
 max-stats::
 	Set the default maximum statistics period. Valid values are "week",
 	"month", "quarter" and "year". If unspecified, statistics are
diff --git a/ui-tree.c b/ui-tree.c
index f53ab64..f281937 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -107,6 +107,12 @@ static void print_object(const unsigned char *sha1, char *path, const char *base
 		        curr_rev, path);
 	htmlf(")<br/>blob: %s\n", sha1_to_hex(sha1));
 
+	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))
 		print_binary_buffer(buf, size);
 	else
d>June McEnroe 2019-09-12Consume entire bodyJune McEnroe Aborting the request and leaving data around may be causing intermittent errors. Just discard the rest of the data. 2019-09-10Add title -v flagJune McEnroe 2019-09-10Use curl error bufferJune McEnroe 2019-09-10Set Accept-Encoding in titleJune McEnroe Because apparently it's fine for servers to respond with Content-Encoding you didn't ask for, and curl won't decode it if you didn't ask for it. 2019-09-08Set title User-AgentJune McEnroe Some things don't like you if you don't send one. 2019-09-07Add -x flag to titleJune McEnroe 2019-09-07Ignore SIGPIPE in relayJune McEnroe Allows restarting consumers safely. 2019-09-07Add A Memory Called EmpireJune McEnroe 2019-09-05Handle lack of Content-TypeJune McEnroe 2019-09-05Use CURLINFO_CONTENT_TYPEJune McEnroe Oops, didn't see this. 2019-09-05Decode entities in titlesJune McEnroe 2019-09-05Print title as soon as it's availableJune McEnroe 2019-09-05Use CURL_PREFIX to set flagsJune McEnroe 2019-09-05Add titleJune McEnroe 2019-09-04Add Avorter n'est pas tuerJune McEnroe 2019-08-29Unset executable on shell scriptsJune McEnroe 2019-08-29Add long-missing setopt to bin.7June McEnroe 2019-08-29Add editJune McEnroe