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-tree.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/ui-tree.c') diff --git a/source/ui-tree.c b/source/ui-tree.c index 7d24d53..7df7375 100644 --- a/source/ui-tree.c +++ b/source/ui-tree.c @@ -191,7 +191,10 @@ static bool print_object(const struct object_id *oid, const char *path, "Error reading object %s", oid_to_hex(oid)); return false; } - is_binary = buffer_is_binary(buf, size); + // buffer_is_binary only sniffs the front of the blob, and a NUL past + // that window would end the escaped text render early while the line + // number column still counts the whole file, so check the rest too. + is_binary = buffer_is_binary(buf, size) || memchr(buf, 0, size); cgit_set_title_from_path(path); -- cgit v2.8.0