From 57c0a9eb17d89de735836739e5e8f7c69505d21e Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 6 Oct 2020 13:21:29 +0200 Subject: [PATCH] Bug 20582: Reset CGI::PARAM_UTF8 to 1 before each CGI request CGI::Compile calls CGI::initialize_globals before each request, which resets PARAM_UTF8 to 0 We need to set it back to the correct value This is the same trick used in debian/templates/plack.psgi --- Koha/App/Plugin/CGIBinKoha.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Koha/App/Plugin/CGIBinKoha.pm b/Koha/App/Plugin/CGIBinKoha.pm index 6c07743630..b7b8d4680b 100644 --- a/Koha/App/Plugin/CGIBinKoha.pm +++ b/Koha/App/Plugin/CGIBinKoha.pm @@ -21,6 +21,7 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Plugin'; +use CGI; use CGI::Compile; use CGI::Emulate::PSGI; use IO::Scalar; @@ -28,6 +29,17 @@ use IO::Scalar; sub register { my ($self, $app, $conf) = @_; + # CGI::Compile calls CGI::initialize_globals before each request, which resets PARAM_UTF8 to 0 + # We need to set it back to the correct value + { + no warnings 'redefine'; + my $old_new = \&CGI::new; + *CGI::new = sub { + $CGI::PARAM_UTF8 = 1; + return $old_new->(@_); + }; + } + my $opac = $conf->{opac}; my $r = $app->routes; -- 2.20.1