git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Tatsuki Sugiura" <sugi@nemui.org>,
	git@vger.kernel.org, "Gerrit Pape" <pape@smarden.org>,
	"Recai Oktaş" <roktas@debian.org>
Subject: Re: [PATCH] gitweb: fix encode handling for site_{header,footer}
Date: Mon, 17 Nov 2008 11:40:44 +0100	[thread overview]
Message-ID: <200811171140.45884.jnareb@gmail.com> (raw)
In-Reply-To: <7v8wrizlxo.fsf@gitster.siamese.dyndns.org>

On Mon, 17 Nov 2008, Junio C Hamano wrote:
> Tatsuki Sugiura <sugi@nemui.org> writes:
> 
> > All non-ASCII chars of site_{header,footer} will be broken
> > by perl IO layer without decoding to utf8.
> >
> > Here is a fix to just call to_utf8 for inputs from these files.
> >
> > Signed-off-by: Tatsuki Sugiura <sugi@nemui.org>
> 
> Looks good, thanks.

Hmmm... it is good _partial_ solution. I wonder if gitweb doesn't
have the same problem with per-project README.html file...

> > ---
> >  gitweb/gitweb.perl |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> > index 933e137..79ca5c2 100755
> > --- a/gitweb/gitweb.perl
> > +++ b/gitweb/gitweb.perl
> > @@ -2929,7 +2929,7 @@ EOF
> >  
> >  	if (-f $site_header) {
> >  		open (my $fd, $site_header);
> > -		print <$fd>;
> > +		print map {to_utf8($_)} <$fd>;
> >  		close $fd;
> >  	}
> >  
> > @@ -3018,7 +3018,7 @@ sub git_footer_html {
> >  
> >  	if (-f $site_footer) {
> >  		open (my $fd, $site_footer);
> > -		print <$fd>;
> > +		print map {to_utf8($_)} <$fd>;
> >  		close $fd;
> >  	}
> >  
> > -- 
> > 1.5.6.5

There was some patch by Recai Oktaş, or Gerrit Pape (or me)


diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 4c104d2..8b5fcc1 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -16,7 +16,7 @@ use Encode;
 use Fcntl ':mode';
 use File::Find qw();
 use File::Basename qw(basename);
-binmode STDOUT, ':utf8';
+use open qw(:std :utf8);
 
 BEGIN {
 	CGI->compile() if $ENV{'MOD_PERL'};


Then to_utf8() wouldn't be necessary. But I'd like for Perl experts to 
check it first; for example this doesn't allow $fallback_encoding.

-- 
Jakub Narębski
Poland

  reply	other threads:[~2008-11-17 10:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-17  7:53 [PATCH] gitweb: fix encode handling for site_{header,footer} Tatsuki Sugiura
2008-11-17 10:28 ` Junio C Hamano
2008-11-17 10:40   ` Jakub Narebski [this message]
2008-12-01 18:01     ` [PATCH] gitweb: Fix handling of non-ASCII characters in inserted HTML files Jakub Narebski
2008-12-03  3:55       ` Junio C Hamano
2008-12-03 10:21         ` Jakub Narebski
2008-12-03 21:14           ` Junio C Hamano
2008-12-08 13:13             ` [PATCH] gitweb: Fix bug in insert_file() subroutine Jakub Narebski
2008-12-08 17:05               ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200811171140.45884.jnareb@gmail.com \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pape@smarden.org \
    --cc=roktas@debian.org \
    --cc=sugi@nemui.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).