From 5754faeb3fa1c9aaeff8922b449127cfbc86236d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 9 Oct 2023 17:56:23 +0000 Subject: www_coderepo: fix handling of non-UTF-8 git data We can't assume git output is UTF-8, and we'll always have legacy data in git coderepos. So attempt to display some some garbled text rather than nothing at all if Perl croaks on it. sox commit c38987e8d20505621b8d872863afa7d233ed1096 (Added raw inverse-bit u-law and A-law support. Updated *.txt files., 2001-12-13) is an example of a commit which caused problems for me. --- lib/PublicInbox/ViewDiff.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/ViewDiff.pm') diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm index 124a723a..d078c5f9 100644 --- a/lib/PublicInbox/ViewDiff.pm +++ b/lib/PublicInbox/ViewDiff.pm @@ -11,7 +11,7 @@ use v5.12; use parent qw(Exporter); our @EXPORT_OK = qw(flush_diff uri_escape_path); use URI::Escape qw(uri_escape_utf8); -use PublicInbox::Hval qw(ascii_html to_attr); +use PublicInbox::Hval qw(ascii_html to_attr utf8_maybe); use PublicInbox::Git qw(git_unquote); my $OID_NULL = '0{7,}'; @@ -236,7 +236,7 @@ sub flush_diff ($$) { } } if (!$dctx) { - utf8::decode($after); + utf8_maybe($after); diff_before_or_after($ctx, \$after); } } else { -- cgit v1.2.3-24-ge0c7