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

Re: [RFD] Handling of non-UTF8 data in gitweb

From
Jakub Narebski <jnareb@gmail.com>
Date
Jan 6, 2012, 16:35 UTC
Message-ID
<201201061735.32908.jnareb@gmail.com>
In-Reply-To
<201112041709.32212.jnareb@gmail.com>
On Sun, 4 Dec 2011, Jakub Narebski wrote:
> 
> Currently gitweb converts data it receives from git commands to Perl 
> internal utf8 representation via to_utf8() subroutine
[...]
Show 14 quoted lines
> Each part of data must be handled separately.  It is quite error prone
> process, as can be seen from quite a number of patches that fix handling
> of UTF-8 data (latest from Jürgen).
> 
> 
> Much, much simpler would be to force opening of all files (including 
> output pipes from git commands) in ':utf8' mode:
> 
>   use open qw(:std :utf8);
> 
> [Note: perhaps instead of ':utf8' it should be ':encoding(UTF-8)' 
>  there...]
> 
> But doing this would change gitweb behavior.  [...]
[...]
> I don't know if people are relying on the old behavior.  I guess
> it could be emulated by defining our own 'utf-8-with-fallback'
> encoding, or by defining our own PerlIO layer with PerlIO::via.
> But it no longer be simple solution (though still automatic).
I have now created simple Encode::UTF8WithFallback module, so that
  use Encode::UTF8WithFallback;
  use open IN => ':encoding(utf8-with-fallback)';

should be able to replace all calls to to_utf8() without any change in behavior; at least simple tests shows that.

There however are two problems with this solution:
1. Encode::UTF8WithFallback should really be a separate Perl module
   in a separate file (e.g. 'gitweb/lib/Encode/UTF8WithFallback.pm');
   I was not able to make it work without a separate file.
   This means that it very much requires the change that allows splitting
   gitweb into many files and/or load extra helper modules, and/or require
   extra non-core modules but provide and install them with gitweb if they
   are not available.  These changes are ready, and can be find in 
     'gitweb/split'
   
   branch in my git.git repositories:
     http://repo.or.cz/w/git/jnareb-git.git
     https://github.com/jnareb/git
2. It turned out that the "open" pragma 1.04 from Perl v5.8.6 does not
   work correctly.  We need at least "open" 1.06 (version 1.05 consists
   supposedly only of documentation-only change).
   Because "open" is a core Perl module (core pragma), this means that
   gitweb will require in practice Perl v5.8.9 at least, increasing
   version requirement from current v5.8.0
 
-- 
Jakub Narebski
Poland
Previous: Jakub Narebski
Message 7 of 7 in “[RFD] Handling of non-UTF8 data in gitweb”
  1. Jakub NarebskiDec 4, 2011
  2. Jeff KingDec 6, 2011
  3. Junio C HamanoDec 7, 2011
  4. Jakub NarebskiDec 10, 2011
  5. Junio C HamanoDec 12, 2011
  6. Jakub NarebskiDec 18, 2011
  7. Jakub NarebskiJan 6, 2012

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.