aboutsummaryrefslogtreecommitdiffstats
path: root/ui-blame.c
diff options
context:
space:
mode:
authorJune McEnroe2019-12-18 21:30:12 +0000
committerYigit Sever2023-07-21 03:03:49 +0300
commit1c9e818ddb4ad4601f3180cd9163625bd087f03a (patch)
tree8c27ec40c2f0a5e00c412dfed05360a340e12992 /ui-blame.c
parentcafd9178eb039f859fbdc85c5c006331e3222f33 (diff)
downloadcgit-1c9e818ddb4ad4601f3180cd9163625bd087f03a.tar.gz
cgit-1c9e818ddb4ad4601f3180cd9163625bd087f03a.tar.bz2
cgit-1c9e818ddb4ad4601f3180cd9163625bd087f03a.zip
ui-tree,ui-blame: bail from blame if blob is binary
This avoids piping binary blobs through the source-filter. Also prevent robots from crawling it, since it's expensive. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'ui-blame.c')
-rw-r--r--ui-blame.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/ui-blame.c b/ui-blame.c
index 03136f7..4adec2b 100644
--- a/ui-blame.c
+++ b/ui-blame.c
@@ -152,6 +152,10 @@ static void print_object(const struct object_id *oid, const char *path,
152 cgit_tree_link("tree", NULL, NULL, ctx.qry.head, rev, path); 152 cgit_tree_link("tree", NULL, NULL, ctx.qry.head, rev, path);
153 html(")\n"); 153 html(")\n");
154 154
155 if (buffer_is_binary(buf, size)) {
156 html("<div class='error'>blob is binary.</div>");
157 goto cleanup;
158 }
155 if (ctx.cfg.max_blob_size && size / 1024 > ctx.cfg.max_blob_size) { 159 if (ctx.cfg.max_blob_size && size / 1024 > ctx.cfg.max_blob_size) {
156 htmlf("<div class='error'>blob size (%ldKB)" 160 htmlf("<div class='error'>blob size (%ldKB)"
157 " exceeds display size limit (%dKB).</div>", 161 " exceeds display size limit (%dKB).</div>",