From c4fdc1d10e282e4c6690b86ce5aea7315ecdb3fc Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:32:43 -0700 Subject: Escape a unified diff line by its length --- source/ui-diff.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'source') diff --git a/source/ui-diff.c b/source/ui-diff.c index 260aed2..58df894 100644 --- a/source/ui-diff.c +++ b/source/ui-diff.c @@ -187,15 +187,9 @@ static int show_filepair(struct diff_filepair *pair) starts_with(pair->two->path, current_prefix); } -/* - * The line xdiff produces ends in its newline, which is swapped for a - * terminator while the text is escaped and then put back, because the line - * points into a buffer xdiff still owns. - */ static void print_line(char *line, int len) { const char *class = "ctx"; - char c = line[len - 1]; if (line[0] == '+') class = "add"; @@ -205,10 +199,8 @@ static void print_line(char *line, int len) class = "hunk"; htmlf("
", class); - line[len - 1] = '\0'; - html_txt(line); + html_ntxt(line, len - 1); html("
"); - line[len - 1] = c; } static void print_file_header(const struct object_id *old_oid, const char *old_path, unsigned old_mode, -- cgit