From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C025A1F54E for ; Mon, 22 Aug 2022 06:44:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1661150652; bh=2Q3ohryTi7QER7QpvokPlzpBBJpzqDmducBROuhmVJ8=; h=Date:From:To:Subject:References:In-Reply-To:From; b=euqLPOL8cXuwP2nroQWBBTnv648s6zitCTZRWvWqJl4lSpKd7+Yec3oY4OVgtUytK S4rGK076fLItjCf6JndAZzVz/i4PWFFnBC7jPd4JxCcXkh0AkztaEKuqegcmryXgw7 e55IDSKdOwUpQ5lChKbQaUEcrhxfqQ+MtlbDnBds= Date: Mon, 22 Aug 2022 06:44:12 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 8/7] viewvcs: use :utf8 for opening patch, too Message-ID: <20220822064412.M654462@dcvr> References: <20220822023346.938859-1-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220822023346.938859-1-e@80x24.org> List-Id: 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 $s\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 $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 +# Copyright (C) all contributors # License: AGPL-3.0+ 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éanor/, + 'UTF-8 commit shown properly'); }; test_psgi(sub { $www->call(@_) }, $client); SKIP: {