Skip to content

Instantly share code, notes, and snippets.

@lucaswerkmeister
Created November 1, 2021 16:45
Show Gist options
  • Save lucaswerkmeister/5dd286557cab3203cc9632c9a5460ad0 to your computer and use it in GitHub Desktop.
Save lucaswerkmeister/5dd286557cab3203cc9632c9a5460ad0 to your computer and use it in GitHub Desktop.
GitWeb wrapper to fix UTF-8 in FastCGI (no longer needed in Debian Bullseye)
#!/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/share/gitweb/gitweb.cgi";
@lucaswerkmeister
Copy link
Author

@lucaswerkmeister
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment