From a969570d917a2f09c459d3526c846187e11cfffd Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 11 Apr 2014 15:45:10 +0200 Subject: [PATCH] Bug 11944: Fix encoding issue on adding a subscription If frequencies or numbering patterns contain non-latin characters, so output was broken. To reproduce: - Create a frequency and a numbering pattern with non-latin characters - Add a new subscription using these values - The screen should not contain bad encoded characters. --- serials/subscription-frequency.pl | 6 +++--- serials/subscription-numberpattern.pl | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/serials/subscription-frequency.pl b/serials/subscription-frequency.pl index 6d3b7e1..f7fe7c0 100755 --- a/serials/subscription-frequency.pl +++ b/serials/subscription-frequency.pl @@ -17,12 +17,12 @@ # You should have received a copy of the GNU General Public License # along with Koha; if not, see . +use Modern::Perl; use CGI qw ( -utf8 ); use C4::Context; use C4::Serials::Frequency; use C4::Auth qw/check_cookie_auth/; -use URI::Escape; -use strict; +use JSON qw( to_json ); my $input=new CGI; my $frqid=$input->param("frequency_id"); @@ -33,4 +33,4 @@ if ($auth_status ne "ok") { my $frequencyrecord=GetSubscriptionFrequency($frqid); binmode STDOUT, ":encoding(UTF-8)"; print $input->header(-type => 'text/plain', -charset => 'UTF-8'); -print "{".join (",",map { "\"$_\":\"".uri_escape_utf8($frequencyrecord->{$_})."\"" }sort keys %$frequencyrecord)."}"; +print to_json( $frequencyrecord ); diff --git a/serials/subscription-numberpattern.pl b/serials/subscription-numberpattern.pl index cf0fdfa..26745f1 100755 --- a/serials/subscription-numberpattern.pl +++ b/serials/subscription-numberpattern.pl @@ -21,7 +21,7 @@ use Modern::Perl; use CGI qw ( -utf8 ); use C4::Serials::Numberpattern; use C4::Auth qw/check_cookie_auth/; -use URI::Escape; +use JSON qw( to_json ); my $input=new CGI; @@ -34,6 +34,7 @@ if ($auth_status ne "ok") { my $numpatternid=$input->param("numberpattern_id"); my $numberpatternrecord=GetSubscriptionNumberpattern($numpatternid); + binmode STDOUT, ":encoding(UTF-8)"; print $input->header(-type => 'text/plain', -charset => 'UTF-8'); -print "{",join (",",map {"\"$_\":\"".(uri_escape_utf8($numberpatternrecord->{$_}) // '')."\"" }sort keys %$numberpatternrecord),"}"; +print to_json( $numberpatternrecord ); -- 1.7.10.4