summaryrefslogtreecommitdiffstats
path: root/roles/git/files/usr/lib/cgi-bin/gitweb-wrapper.fcgi
blob: a7eea8c38385c3f6bd961b36dddf2711e5600ef8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl
# gitweb.cgi wrapper that fixes the UTF-8 problem with fastcgi

# Local redefinition of FCGI::Stream::PRINT
use Encode;
use FCGI;

our $enc = Encode::find_encoding('UTF-8');
our $org = \&FCGI::Stream::PRINT;
no warnings 'redefine';

local *FCGI::Stream::PRINT = sub {
  my @OUTPUT = @_;
  for (my $i = 1; $i < @_; $i++) {
    $OUTPUT[$i] = $enc->encode($_[$i], Encode::FB_CROAK|Encode::LEAVE_SRC);
  }
  @_ = @OUTPUT;
  goto $org;
};

# Execute original script
do "/usr/lib/cgi-bin/gitweb.cgi";