Bug 13815 - plack loose CGI qw(-utf8) flag creating incorrect utf-8 encoding everywhere

This is major problem for plack installations with utf-8 encoding.

In this case, we are overriding CGI->new to setup utf-8 flag and
get correctly decoded $cgi->params, and reset syspref cache using
C4::Context->clear_syspref_cache

Test scenario:
1. under plack try to search with utf-8 charactes
2. try to find patron with utf-8 characters

Signed-off-by: Gaetan Boisson <gaetan.boisson@biblibre.com>

Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
(cherry picked from commit 3cd086b6b6)
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
This commit is contained in:
Dobrica Pavlinusic 2015-03-10 13:35:03 +01:00 committed by Liz Rea
parent 433f4628b2
commit af127c124f
1 changed files with 12 additions and 0 deletions

View File

@ -5,6 +5,18 @@ use lib qw( ./lib );
use Plack::Middleware::Debug;
use Plack::App::Directory;
use CGI qw(-utf8 ); # we will loose -utf8 under plack
{
no warnings 'redefine';
my $old_new = \&CGI::new;
*CGI::new = sub {
my $q = $old_new->( @_ );
$CGI::PARAM_UTF8 = 1;
C4::Context->clear_syspref_cache();
return $q;
};
}
BEGIN {
# override configuration from startup script below: