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

Re: [PATCH] gitweb: convert from perl internal to utf8 for commitdiff_plain

From
IDIsmail Dönmez <ismail@pardus.org.tr>
Date
Jan 29, 2008, 03:11 UTC
Message-ID
<200801290511.31025.ismail@pardus.org.tr>
In-Reply-To
<87ve5dicih.wl@mail2.atmark-techno.com>
At Tuesday 29 January 2008 around 04:14:00 Yasushi SHOJI wrote:
Show 51 quoted lines
> commitdiff with raw, or plain format if you are reading the code,
> doesn't convert any word from perl internal to utf8, which is set to
> charset in http header.  this cause a problem when commit includes non
> ascii code.
>
> here is a few example in the git tree:
>
> http://git.kernel.org/?p=git/git.git;a=commitdiff_plain;h=6ba78238a82428281
>6944550edc4297dd2808a72
> http://git.kernel.org/?p=git/git.git;a=commitdiff_plain;h=e360bebf713b6b037
>68c62de8b94ddf9350b0953
> http://git.kernel.org/?p=git/git.git;a=commitdiff_plain;h=9459aa77a032621a2
>9d53605542844641cca843a
>
> This patch effectively revert the commitdiff plain part of the commit
>
> 	59b9f61a3f76762dc975e99cc05335a3b97ad1f9
>
> which converted from print to here-doc. but it doesn't
> explain why in the commit log.
> ---
>  gitweb/gitweb.perl |   12 ++++++------
>  1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 6256641..5d9ac1d 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -5048,16 +5048,16 @@ sub git_commitdiff {
>  			-expires => $expires,
>  			-content_disposition => 'inline; filename="' . "$filename" . '"');
>  		my %ad = parse_date($co{'author_epoch'}, $co{'author_tz'});
> -		print <<TEXT;
> -From: $co{'author'}
> -Date: $ad{'rfc2822'} ($ad{'tz_local'})
> -Subject: $co{'title'}
> -TEXT
> +		print "From: " . to_utf8($co{'author'}) . "\n";
> +		print "Date: " . to_utf8($ad{'rfc2822'}) . " "
> +			       . to_utf8($ad{'tz_local'}) . "\n";
> +		print "Subject: " . to_utf8($co{'title'}) . "\n";
> +
>  		print "X-Git-Tag: $tagname\n" if $tagname;
>  		print "X-Git-Url: " . $cgi->self_url() . "\n\n";
>
>  		foreach my $line (@{$co{'comment'}}) {
> -			print "$line\n";
> +			print to_utf8($line) . "\n";
>  		}
>  		print "---\n\n";
>  	}

Nice find, looks correct. You could print "Date" on one line instead of two, but FWIW

Acked-by: İsmail Dönmez <ismail@pardus.org.tr>
-- 
Never learn by your mistakes, if you do you may never dare to try again.
Previous: Yasushi SHOJINext: Junio C Hamano
Message 2 of 9 in “gitweb: convert from perl internal to utf8 for commitdiff_plain”
  1. gitweb: convert from perl internal to utf8 for commitdiff_plainYasushi SHOJI, Jan 29, 2008
  2. Ismail DönmezJan 29, 2008
  3. Junio C HamanoJan 29, 2008
  4. Yasushi SHOJIJan 29, 2008
  5. Junio C HamanoJan 29, 2008
  6. Yasushi SHOJIJan 29, 2008
  7. Jakub NarebskiJan 29, 2008
  8. Junio C HamanoJan 30, 2008
  9. Jakub NarebskiJan 29, 2008

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.