Fixes the encoding for several _plain actions and for text/* and */*+xml blobs. 

Signed-off-by: Jürgen Kreileder <j...@blackdown.de>
---
 gitweb/gitweb.perl |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 1309196..9cfe5b5 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3823,7 +3823,7 @@ sub blob_contenttype {
        my ($fd, $file_name, $type) = @_;
 
        $type ||= blob_mimetype($fd, $file_name);
-       if ($type eq 'text/plain' && defined $default_text_plain_charset) {
+       if (($type =~ m!^text/\w[-\w]*$! || $type =~ 
m!^\w[-\w]*/\w[-\w]*\+xml$!) && defined $default_text_plain_charset) {
                $type .= "; charset=$default_text_plain_charset";
        }
 
@@ -7637,7 +7637,9 @@ sub git_blobdiff {
                        last if $line =~ m!^\+\+\+!;
                }
                local $/ = undef;
+               binmode STDOUT, ':raw';
                print <$fd>;
+               binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
                close $fd;
        }
 }
@@ -7884,12 +7886,16 @@ sub git_commitdiff {
 
        } elsif ($format eq 'plain') {
                local $/ = undef;
+               binmode STDOUT, ':raw';
                print <$fd>;
+               binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
                close $fd
                        or print "Reading git-diff-tree failed\n";
        } elsif ($format eq 'patch') {
                local $/ = undef;
+               binmode STDOUT, ':raw';
                print <$fd>;
+               binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
                close $fd
                        or print "Reading git-format-patch failed\n";
        }
-- 
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to