From f7120603edc6f2680ad01fdbe7b3dc7ddf1494ef Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 27 Sep 2026 21:02:41 -1000 Subject: Share the max-blob-size check and its refusal Five copies of the test and four of the error page had to agree by hand. The new check pins the four refusals, which no test covered. --- source/ui-plain.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'source/ui-plain.c') diff --git a/source/ui-plain.c b/source/ui-plain.c index 2463cfc..136e1f4 100644 --- a/source/ui-plain.c +++ b/source/ui-plain.c @@ -58,11 +58,8 @@ static void print_object(const struct object_id *oid, const char *path) return; } - // The limit counts kilobytes and is checked before the read, so a huge - // blob is kept out of memory rather than noticed once it is there. - if (ctx.cfg.max_blob_size && size / 1024 > (unsigned long)ctx.cfg.max_blob_size) { - cgit_print_error_page(413, "Content Too Large", "Blob size (%lu KB) exceeds the limit (%d KB)", - size / 1024, ctx.cfg.max_blob_size); + if (cgit_blob_too_large(size)) { + cgit_print_blob_too_large(size); return; } -- cgit 2.12.1