From: Junio C Hamano Date: Tue, 10 May 2016 20:40:33 +0000 (-0700) Subject: Merge branch 'sk/gitweb-highlight-encoding' X-Git-Tag: v2.9.0-rc0~52 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/04bd6da2dc9c12f5bff29bc81c037891ef7ed230?ds=inline;hp=-c Merge branch 'sk/gitweb-highlight-encoding' Some multi-byte encoding can have a backslash byte as a later part of one letter, which would confuse "highlight" filter used in gitweb. * sk/gitweb-highlight-encoding: gitweb: apply fallback encoding before highlight --- 04bd6da2dc9c12f5bff29bc81c037891ef7ed230 diff --combined gitweb/gitweb.perl index 05d7910b7c,17ff394923..2fddf750fa --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@@ -3935,6 -3935,9 +3935,9 @@@ sub run_highlighter 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"); @@@ -7576,7 -7579,7 +7579,7 @@@ sub git_object 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");