Re: [PATCH] gitweb: fix encode handling for site_{header,footer}

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 17 Nov 2008, Junio C Hamano wrote:
> Tatsuki Sugiura <sugi@xxxxxxxxx> 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@xxxxxxxxx>
> 
> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux