From bf65ef15fa9671d066e6b9fe77fd898648677299 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. Signed-off-by: Paola Rossi Signed-off-by: Bernardo Gonzalez Kriegel --- .../prog/en/modules/serials/subscription-add.tt | 16 ++++++++-------- serials/subscription-frequency.pl | 6 +++--- serials/subscription-numberpattern.pl | 5 +++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt index 62da614..99141f6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -128,7 +128,7 @@ function displaymoreoptions() { } var X = 0, Y = 0, Z = 0; - var numberingmethod = unescape(globalnumpatterndata.numberingmethod); + var numberingmethod = globalnumpatterndata.numberingmethod; if(numberingmethod.match(/{X}/)) X = 1; if(numberingmethod.match(/{Y}/)) Y = 1; if(numberingmethod.match(/{Z}/)) Z = 1; @@ -141,7 +141,7 @@ function displaymoreoptions() { if(X) { if(globalnumpatterndata.label1) { - $("#headerX").html(unescape(globalnumpatterndata.label1)); + $("#headerX").html(globalnumpatterndata.label1); } else { $("#headerX").html("X"); } @@ -157,7 +157,7 @@ function displaymoreoptions() { } if(Y) { if(globalnumpatterndata.label2) { - $("#headerY").html(unescape(globalnumpatterndata.label2)); + $("#headerY").html(globalnumpatterndata.label2); } else { $("#headerY").html("Y"); } @@ -173,7 +173,7 @@ function displaymoreoptions() { } if(Z) { if(globalnumpatterndata.label3) { - $("#headerZ").html(unescape(globalnumpatterndata.label3)); + $("#headerZ").html(globalnumpatterndata.label3); } else { $("#headerZ").html("Z"); } @@ -212,8 +212,8 @@ function modifyAdvancedPattern() { } function restoreAdvancedPattern() { - $("#patternname").attr("readonly", true).val(unescape(globalnumpatterndata.label)); - $("#numberingmethod").attr("readonly", true).val(unescape(globalnumpatterndata.numberingmethod)); + $("#patternname").attr("readonly", true).val(globalnumpatterndata.label); + $("#numberingmethod").attr("readonly", true).val(globalnumpatterndata.numberingmethod); $("#advancedpredictionpatternt input").each(function() { $(this).attr("readonly", true); @@ -222,13 +222,13 @@ function restoreAdvancedPattern() { var tempid = id.replace(/(\d)/, "temp$1"); $(this).val($("#"+tempid).val()); } else { - $(this).val(unescape(globalnumpatterndata[id])); + $(this).val(globalnumpatterndata[id]); } }); $("#advancedpredictionpatternt select").each(function() { $(this).attr("disabled", true); var id = $(this).attr('id'); - $(this).val(unescape(globalnumpatterndata[id])); + $(this).val(globalnumpatterndata[id]); }); $("#restoreadvancedpatternbutton").hide(); diff --git a/serials/subscription-frequency.pl b/serials/subscription-frequency.pl index 80c7440..1d38082 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; 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 a58b10a..2a59d02 100755 --- a/serials/subscription-numberpattern.pl +++ b/serials/subscription-numberpattern.pl @@ -21,7 +21,7 @@ use Modern::Perl; use CGI; 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