]> WPIA git - infra.git/blob - modules/gitweb/files/gitweb-wrapper.cgi
upd: run git daemon as nobody, not git
[infra.git] / modules / gitweb / files / gitweb-wrapper.cgi
1 #!/usr/bin/perl
2 # gitweb.cgi wrapper that fixes the UTF-8 problem with fastcgi
3
4 # Local redefinition of FCGI::Stream::PRINT
5 use Encode;
6 use FCGI;
7
8 our $enc = Encode::find_encoding('UTF-8');
9 our $org = \&FCGI::Stream::PRINT;
10 no warnings 'redefine';
11
12 local *FCGI::Stream::PRINT = sub {
13     my @OUTPUT = @_;
14     for (my $i = 1; $i < @_; $i++) {
15         $OUTPUT[$i] = $enc->encode($_[$i], Encode::FB_CROAK|Encode::LEAVE_SRC);
16     }
17     @_ = @OUTPUT;
18     goto $org;
19 };
20
21 # Execute original script
22 do "/usr/share/gitweb/gitweb.cgi";