From fbbe14825a72ccb879cd6c7789906264a4fe1db4 Mon Sep 17 00:00:00 2001 From: Fridolyn SOMERS Date: Fri, 18 Jan 2013 15:50:53 +0100 Subject: [PATCH] [SIGNED-OFF] Bug 9425: Template plugins are missing utf8 encoding Content-Type: text/plain; charset="utf-8" Koha custom template plugins KohaAuthorisedValues and KohaBranchName are missing UTF-8 encoding. When they render a value with diacritical characters, those characters are replaced by a sign. Test plan : For KohaAuthorisedValues : - Edit a value of LOST authorized values to have a description with a diacritical character - Edit a biblio to have an item using this authorized value in items.itemlost - Go to OPAC detail page of this biblio => Lost description must be correctly encoded For KohaBranchName : - Choose a serial subscription - Edit its branch to has a diacritical character in name - Go to subscription details : serials/subscription-detail.pl => Library name must be correctly encoded Signed-off-by: Owen Leonard I was finally able to reproduce the problem in the OPAC, but still not in the staff client. However, since it's obvious the patch corrects problems in some situations and doesn't seem to have an adverse effect I'm signing off. --- Koha/Template/Plugin/KohaAuthorisedValues.pm | 4 +++- Koha/Template/Plugin/KohaBranchName.pm | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Koha/Template/Plugin/KohaAuthorisedValues.pm b/Koha/Template/Plugin/KohaAuthorisedValues.pm index 68b1347..85c1421 100644 --- a/Koha/Template/Plugin/KohaAuthorisedValues.pm +++ b/Koha/Template/Plugin/KohaAuthorisedValues.pm @@ -19,6 +19,7 @@ package Koha::Template::Plugin::KohaAuthorisedValues; use Modern::Perl; +use Encode; use Template::Plugin; use base qw( Template::Plugin ); @@ -44,7 +45,8 @@ will print the OPAC description for the LOST value stored in item.itemlost. sub GetByCode { my ( $self, $category, $code, $opac ) = @_; - return GetAuthorisedValueByCode( $category, $code, $opac ); + my $lib = GetAuthorisedValueByCode( $category, $code, $opac ); + return Encode::encode_utf8($lib); } 1; diff --git a/Koha/Template/Plugin/KohaBranchName.pm b/Koha/Template/Plugin/KohaBranchName.pm index a39aba0..81d0184 100644 --- a/Koha/Template/Plugin/KohaBranchName.pm +++ b/Koha/Template/Plugin/KohaBranchName.pm @@ -20,16 +20,18 @@ package Koha::Template::Plugin::KohaBranchName; use strict; use warnings; +use Encode; use Template::Plugin::Filter; use base qw( Template::Plugin::Filter ); use warnings; use strict; -use C4::Branch qw( GetBranchName );; +use C4::Branch qw( GetBranchName ); sub filter { my ($self,$branchcode) = @_; - return GetBranchName( $branchcode ); + my $branchname = GetBranchName( $branchcode ); + return Encode::encode_utf8($branchname); } 1; -- 1.7.9.5