From 0989c0bc6cbd6b3b0605a681034fc3203e0dcab9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 13 Mar 2023 12:00:23 +0000 Subject: lei_mirror: handle UTF-8 from manifest.js.gz properly This should ensure we display the "git config gitweb.owner $OWNER" command invocation properly and also ensures we set the description properly without triggering wide character warnings. Also tested with a smallish iproute2 repo (/pub/scm/linux/kernel/git/toke/iproute2.git) using my mirror: public-inbox-clone --remote-manifest=pub/manifest.js.gz \ --include='*/toke/iproute2.git' --inbox-config=never \ https://80x24.org/lore $DST Anyways, I'm fairly certain this change and its tests are correct; but I still struggle to understand Perl's approach to Unicode and it's interactions with various JSON implementations. Fixes: 0830817c132cb105 ("lei_mirror: show non-ASCII owner properly w/ --verbose") --- lib/PublicInbox/LeiMirror.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox/LeiMirror.pm') diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 3ec8170f..18932cf4 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -259,8 +259,7 @@ sub run_reap { sub start_cmd { my ($self, $cmd, $opt, $fini) = @_; do_reap($self); - utf8::decode(my $msg = "# @$cmd"); - $self->{lei}->qerr($msg); + $self->{lei}->qerr("# @$cmd"); return if $self->{dry_run}; $LIVE->{spawn($cmd, undef, $opt)} = [ \&reap_cmd, $self, $cmd, $fini ] } @@ -633,7 +632,7 @@ sub clone_v1 { } my $d = $self->{-ent} ? $self->{-ent}->{description} : undef; - $self->{'txt.description'} = $d if defined $d; + utf8::encode($self->{'txt.description'} = $d) if defined $d; (!defined($d) && !$end) and _get_txt_start($self, 'description', $fini); @@ -823,6 +822,7 @@ sub update_ent { $new = $self->{-ent}->{owner} // return; $cur = $self->{-local_manifest}->{$key}->{owner} // "\0"; return if $cur eq $new; + utf8::encode($new); # to octets my $cmd = [ qw(git config -f), "$dst/config", 'gitweb.owner', $new ]; start_cmd($self, $cmd, { 2 => $self->{lei}->{2} }); } -- cgit v1.2.3-24-ge0c7