user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 8/7] viewvcs: use :utf8 for opening patch, too
Date: Mon, 22 Aug 2022 06:44:12 +0000	[thread overview]
Message-ID: <20220822064412.M654462@dcvr> (raw)
In-Reply-To: <20220822023346.938859-1-e@80x24.org>

We'll also force --encoding=UTF-8 for "git show" even
if that's the default in git, since the rest of our code
already assumes UTF-8.
---
 lib/PublicInbox/ViewVCS.pm | 8 +++++---
 t/solver_git.t             | 7 ++++++-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index 96883f6c..19d34092 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -144,7 +144,7 @@ committer $co$patchid
 <b>$s</b>\n
 EOM
 	$ctx->zmore($bdy);
-	open $fh, '<', "$tmp/p" or die "open $tmp/p: $!";
+	open $fh, '<:utf8', "$tmp/p" or die "open $tmp/p: $!";
 	if (-s $fh > $MAX_SIZE) {
 		$ctx->zmore("---\n patch is too large to show\n");
 	} else { # prepare flush_diff:
@@ -171,8 +171,10 @@ sub show_commit ($$$$) {
 	# a patch embedded inside the commit message body doesn't get fed
 	# to patch-id:
 	my $cmd = [ '/bin/sh', '-c',
-		"git show '$SHOW_FMT' -z --no-notes --no-patch $oid >h && ".
-		"git show --pretty=format:%n -M --stat -p $oid >p && ".
+		"git show --encoding=UTF-8 '$SHOW_FMT'".
+		" -z --no-notes --no-patch $oid >h && ".
+		'git show --encoding=UTF-8 --pretty=format:%n -M'.
+		" --stat -p $oid >p && ".
 		"git patch-id --stable <p" ];
 	my $xenv = { GIT_DIR => $git->{git_dir} };
 	my $tmp = File::Temp->newdir("show-$oid-XXXX", TMPDIR => 1);
diff --git a/t/solver_git.t b/t/solver_git.t
index 1baa012b..5c7bfa28 100644
--- a/t/solver_git.t
+++ b/t/solver_git.t
@@ -1,5 +1,5 @@
 #!perl -w
-# Copyright (C) 2019-2021 all contributors <meta@public-inbox.org>
+# Copyright (C)  all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 use strict;
 use v5.10.1;
@@ -294,6 +294,11 @@ EOF
 			is($res->content, "\0" x $size,
 				"$label content matches");
 		}
+		my $utf8 = 'e022d3377fd2c50fd9931bf96394728958a90bf3';
+		$res = $cb->(GET("/$name/$utf8/s/"));
+		is($res->code, 200, 'shows commit w/ utf8.eml');
+		like($res->content, qr/El&#233;anor/,
+				'UTF-8 commit shown properly');
 	};
 	test_psgi(sub { $www->call(@_) }, $client);
 	SKIP: {

  parent reply	other threads:[~2022-08-22  6:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-22  2:33 [PATCH 0/7] an even bigger git show than before Eric Wong
2022-08-22  2:33 ` [PATCH 1/7] config: fix confusing space in ->repo_objs Eric Wong
2022-08-22  2:33 ` [PATCH 2/7] xt/solver: improve diagnostics Eric Wong
2022-08-22  2:33 ` [PATCH 3/7] www: /s/: 404 for unconfigured coderepos Eric Wong
2022-08-22  2:33 ` [PATCH 4/7] qspawn: add type comments in a few places Eric Wong
2022-08-22  2:33 ` [PATCH 5/7] qspawn: improve error reporting and handling Eric Wong
2022-08-22  2:33 ` [PATCH 6/7] viewvcs: drop pointless variable assignment Eric Wong
2022-08-22  2:33 ` [PATCH 7/7] viewvcs: start improving display of git commits Eric Wong
2022-08-22  6:44 ` Eric Wong [this message]
2022-08-22 19:34 ` extindex for git? [was: an even bigger git show than before...] Eric Wong
2022-08-25 21:34   ` Eric Wong
2022-08-26 16:51     ` Konstantin Ryabitsev
2022-08-26 18:11       ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220822064412.M654462@dcvr \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).