Created
November 1, 2021 16:45
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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"; |
Original source was apparently https://git.661346.n2.nabble.com/Gitweb-running-as-FCGI-does-not-print-its-output-in-UTF-8-td7573415.html (archived).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See lucaswerkmeister/server-etc@0d35bc6 and lucaswerkmeister/server-etc@5d38a30.