{"thread":{"id":"63021","subject":"gitweb encoding issues (partial patch)","startedAt":"2025-02-28T06:27:26Z","lastAt":"2025-02-28T06:27:26Z","messageCount":1,"participants":["Thorsten Glaser"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"513228","messageId":"8e89b5d0-c913-0dcf-7c3a-62de5af02282@debian.org","threadId":"63021","inReplyTo":null,"subject":"gitweb encoding issues (partial patch)","fromName":"Thorsten Glaser","fromEmail":"tg@debian.org","sentAt":"2025-02-28T06:27:12Z","receivedAt":"2025-02-28T06:27:26Z","isPatch":false,"sender":{"key":"tg@debian.org","avatar":"https://avatars.githubusercontent.com/u/861078?v=4"},"body":"Hi again,\n\nI also noticed a mojibake issue: a git diff that contains UTF-8\nis double-encoded (converted to UTF-8 as if it were latin1 or\nsomething, even if it was already UTF-8), and this seems to be\nindependent of the locale.\n\nI *think* using the to_utf8 sub on the content is the right fix,\nas it seems to check if it’s UTF-8, pass through if it is, and\nencode to UTF-8 (which the HTTP headers say is sent) if it’s not.\n\nPatch which fixes this, for commitdiff_plain and patch for me:\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex b5490dfecf..434b1c01cd 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -8063,12 +8063,12 @@ sub git_commitdiff {\n \n \t} elsif ($format eq 'plain') {\n \t\tlocal $/ = undef;\n-\t\tprint <$fd>;\n+\t\tprint to_utf8(<$fd>);\n \t\tclose $fd\n \t\t\tor print \"Reading git-diff-tree failed\\n\";\n \t} elsif ($format eq 'patch') {\n \t\tlocal $/ = undef;\n-\t\tprint <$fd>;\n+\t\tprint to_utf8(<$fd>);\n \t\tclose $fd\n \t\t\tor print \"Reading git-format-patch failed\\n\";\n \t}\n\nThis might probably need fixing in more places. While scrolling,\nI saw blobdiff; I have not identified all places needed and would\nappreciate the maintainer on your side doing so and fixing them.\n\nThanks in advance,\n//mirabilos\n-- \nI believe no one can invent an algorithm. One just happens to hit upon it\nwhen God enlightens him. Or only God invents algorithms, we merely copy them.\nIf you don't believe in God, just consider God as Nature if you won't deny\nexistence.\t\t-- Coywolf Qi Hunt\n"}]}