Code

gitweb: Fix fallback mode of to_utf8 subroutine
[git.git] / gitweb / gitweb.perl
index a9f39d59cdaec0880106cbdd03f4011d034d9de8..874023a33e9162b99bfa5b0e4038b102c129f6f1 100755 (executable)
@@ -1442,8 +1442,8 @@ sub validate_refname {
 sub to_utf8 {
        my $str = shift;
        return undef unless defined $str;
-       if (utf8::valid($str)) {
-               utf8::decode($str);
+
+       if (utf8::is_utf8($str) || utf8::decode($str)) {
                return $str;
        } else {
                return decode($fallback_encoding, $str, Encode::FB_DEFAULT);
@@ -6108,7 +6108,9 @@ sub git_blame_common {
                        -type=>"text/plain", -charset => "utf-8",
                        -status=> "200 OK");
                local $| = 1; # output autoflush
-               print while <$fd>;
+               while (my $line = <$fd>) {
+                       print to_utf8($line);
+               }
                close $fd
                        or print "ERROR $!\n";