git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/4] gitweb: Fix utf8 encoding for blob_plain, blobdiff_plain, commitdiff_plain, and patch

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 8, 2013, 21:58 UTC
Message-ID
<7vd2u4vg4o.fsf@alter.siamese.dyndns.org>
In-Reply-To
<m2zjx8bxaj.fsf@blackdown.de>
jk@blackdown.de (Jürgen Kreileder) writes:
> Fixes the encoding for several _plain actions and for text/* and */*+xml blobs. 
>
> Signed-off-by: Jürgen Kreileder <jk@blackdown.de>
> ---
Thanks, will queue but not hold until I hear something from Jakub.
Show 43 quoted lines
>  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";
>  	}
Previous: Jürgen KreilederNext: Jakub Narębski
Message 2 of 5 in “gitweb: Fix utf8 encoding for blob_plain, blobdiff_plain, commitdiff_plain, and patch”
  1. 1/4 gitweb: Fix utf8 encoding for blob_plain, blobdiff_plain, commitdiff_plain, and patchJürgen Kreileder, Apr 8, 2013
  2. Junio C HamanoApr 8, 2013
  3. Jakub NarębskiApr 9, 2013
  4. Jürgen KreilederApr 9, 2013
  5. Jakub NarębskiApr 10, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.