From 34c99245b33a3fe23a132ff0df18d64d251a848c Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Fri, 14 Aug 2026 10:58:51 -1000 Subject: Treat text blobs with stray nuls as binary --- source/ui-blame.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source/ui-blame.c') diff --git a/source/ui-blame.c b/source/ui-blame.c index 80512a0..a7010d0 100644 --- a/source/ui-blame.c +++ b/source/ui-blame.c @@ -307,7 +307,19 @@ static void print_blame_page(const struct object_id *oid, const char *path, cgit_tree_link("tree", NULL, NULL, ctx.qry.head, rev, path); html(")\n"); - if (buffer_is_binary(buf, size)) { + // A NUL past the window buffer_is_binary sniffs would end html_txt + // early while the hash and line number columns still cover the whole + // file, so a blob holding one anywhere is treated as binary too. + if (buffer_is_binary(buf, size) || memchr(buf, 0, size)) { + struct blame_entry *ent = sb.ent, *next; + + // The scoreboard is normally consumed by the column passes, + // so this early exit has to release it itself. + for (; ent; ent = next) { + next = ent->next; + free(ent); + } + free((void *)sb.final_buf); html("
blob is binary.
"); goto cleanup; } -- cgit v2.8.0