]> Lady’s Gitweb - Gitweb/blobdiff - gitweb.perl
gitweb: apply fallback encoding before highlight
[Gitweb] / gitweb.perl
index 9956e5991d009314fd0577b7f6ae10f3afc363a1c60de404b7b2d50bc28ca0d5..c19148234ff7ae0956589878b7c0755d53399961a72f4daf712bffd18e4555e6 100755 (executable)
@@ -3936,6 +3936,9 @@ sub run_highlighter {
 
        close $fd;
        open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ".
 
        close $fd;
        open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ".
+                 quote_command($^X, '-CO', '-MEncode=decode,FB_DEFAULT', '-pse',
+                   '$_ = decode($fe, $_, FB_DEFAULT) if !utf8::decode($_);',
+                   '--', "-fe=$fallback_encoding")." | ".
                  quote_command($highlight_bin).
                  " --replace-tabs=8 --fragment --syntax $syntax |"
                or die_error(500, "Couldn't open file or run syntax highlighter");
                  quote_command($highlight_bin).
                  " --replace-tabs=8 --fragment --syntax $syntax |"
                or die_error(500, "Couldn't open file or run syntax highlighter");
@@ -7577,7 +7580,7 @@ sub git_object {
                        git_cmd(), 'cat-file', '-t', $object_id) . ' 2> /dev/null'
                        or die_error(404, "Object does not exist");
                $type = <$fd>;
                        git_cmd(), 'cat-file', '-t', $object_id) . ' 2> /dev/null'
                        or die_error(404, "Object does not exist");
                $type = <$fd>;
-               chomp $type;
+               defined $type && chomp $type;
                close $fd
                        or die_error(404, "Object does not exist");
 
                close $fd
                        or die_error(404, "Object does not exist");
 
This page took 0.154292 seconds and 4 git commands to generate.