diff mbox series

gitweb encoding issues (partial patch)

Message ID 8e89b5d0-c913-0dcf-7c3a-62de5af02282@debian.org (mailing list archive)
State New
Headers show
Series gitweb encoding issues (partial patch) | expand

Commit Message

Thorsten Glaser Feb. 28, 2025, 6:27 a.m. UTC
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:


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
diff mbox series

Patch

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";
 	}