git/list[1] front-page[2] threads[3] people[4] search[5] about
 

gitweb encoding issues (partial patch)

From
Thorsten Glaser <tg@debian.org>
Date
Feb 28, 2025, 06:27 UTC
Message-ID
<8e89b5d0-c913-0dcf-7c3a-62de5af02282@debian.org>
Hi again,

I also noticed a mojibake issue: a git diff that contains UTF-8 is double-encoded (converted to UTF-8 as if it were latin1 or something, even if it was already UTF-8), and this seems to be independent of the locale.

I *think* using the to_utf8 sub on the content is the right fix, as it seems to check if it’s UTF-8, pass through if it is, and encode to UTF-8 (which the HTTP headers say is sent) if it’s not.

Patch which fixes this, for commitdiff_plain and patch for me:
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b5490dfecf..434b1c01cd 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -8063,12 +8063,12 @@ sub git_commitdiff {
 
 	} elsif ($format eq 'plain') {
 		local $/ = undef;
-		print <$fd>;
+		print to_utf8(<$fd>);
 		close $fd
 			or print "Reading git-diff-tree failed\n";
 	} elsif ($format eq 'patch') {
 		local $/ = undef;
-		print <$fd>;
+		print to_utf8(<$fd>);
 		close $fd
 			or print "Reading git-format-patch failed\n";
 	}

This might probably need fixing in more places. While scrolling,
I saw blobdiff; I have not identified all places needed and would
appreciate the maintainer on your side doing so and fixing them.

Thanks in advance,
//mirabilos
-- 
I believe no one can invent an algorithm. One just happens to hit upon it
when God enlightens him. Or only God invents algorithms, we merely copy them.
If you don't believe in God, just consider God as Nature if you won't deny
existence.		-- Coywolf Qi Hunt
Message 1 of 1 in “gitweb encoding issues (partial patch)”
  1. Thorsten GlaserFeb 28, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.