Skip to content

Commit e5d3de5

Browse files
İsmail Dönmezgitster
authored andcommitted
gitweb: use Perl built-in utf8 function for UTF-8 decoding.
Signed-off-by: İsmail Dönmez <ismail@pardus.org.tr> Tested-by: Martin Koegler <mkoegler@auto.tuwien.ac.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent dcbcb70 commit e5d3de5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

gitweb/gitweb.perl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,10 +695,9 @@ sub validate_refname {
695695
# in utf-8 thanks to "binmode STDOUT, ':utf8'" at beginning
696696
sub to_utf8 {
697697
my $str = shift;
698-
my $res;
699-
eval { $res = decode_utf8($str, Encode::FB_CROAK); };
700-
if (defined $res) {
701-
return $res;
698+
if (utf8::valid($str)) {
699+
utf8::decode($str);
700+
return $str;
702701
} else {
703702
return decode($fallback_encoding, $str, Encode::FB_DEFAULT);
704703
}

0 commit comments

Comments
 (0)