Bugzilla – Attachment 82384 Details for
Bug 21848
Resolve unac_string warning from Circulation.t
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21848: Handle encoding when calling Text::Unaccent::unac_string
Bug-21848-Handle-encoding-when-calling-TextUnaccen.patch (text/plain), 2.65 KB, created by
Marcel de Rooy
on 2018-11-16 08:45:00 UTC
(
hide
)
Description:
Bug 21848: Handle encoding when calling Text::Unaccent::unac_string
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-11-16 08:45:00 UTC
Size:
2.65 KB
patch
obsolete
>From 9be2740e319e370887556234ee403d9152ab8060 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 16 Nov 2018 09:30:56 +0100 >Subject: [PATCH] Bug 21848: Handle encoding when calling > Text::Unaccent::unac_string >Content-Type: text/plain; charset=utf-8 > >Resolve warnings like: > unac_string: Invalid or incomplete multibyte or wide character > >Note that Text::Unaccent says: > Return the unaccented equivalent of the string $string. The character set of $string is specified by the $charset argument. The returned string is coded using the same character set. > >The only place we call unac_string is: Koha::Patron->generate_userid: > $userid = unac_string('utf-8',$userid); >Since we say to unac_string that $userid is utf-8, we should first encode it and the result we should decode again for further handling. > >Test plan: >[1] Run t/db_dependent/Koha/Patrons.t >[2] Run t/db_dependent/Circulation.t (before this patch it gave a few warns) > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Patron.pm | 3 ++- > t/db_dependent/Koha/Patrons.t | 5 +++-- > 2 files changed, 5 insertions(+), 3 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 5831034..7e4ba46 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -21,6 +21,7 @@ package Koha::Patron; > use Modern::Perl; > > use Carp; >+use Encode qw/encode_utf8 decode_utf8/; > use List::MoreUtils qw( uniq ); > use JSON qw( to_json ); > use Text::Unaccent qw( unac_string ); >@@ -1313,7 +1314,7 @@ sub generate_userid { > $firstname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g; > $surname =~ s/[[:digit:][:space:][:blank:][:punct:][:cntrl:]]//g; > my $userid = lc(($firstname)? "$firstname.$surname" : $surname); >- $userid = unac_string('utf-8',$userid); >+ $userid = decode_utf8(unac_string('utf-8',encode_utf8($userid))); > $userid .= $offset unless $offset == 0; > $self->userid( $userid ); > $offset++; >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index c552220..52a407d 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -18,6 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >+use utf8; > > use Test::More tests => 34; > use Test::Warn; >@@ -1389,8 +1390,8 @@ subtest 'generate_userid' => sub { > ); > my %data = ( > cardnumber => "123456789", >- firstname => "Tomasito", >- surname => "None", >+ firstname => "TomasÃto", # accent >+ surname => "Ãòñé", # accents > categorycode => $patron_category->categorycode, > branchcode => $library->branchcode, > ); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21848
:
82384
|
82385
|
83146
|
83210
|
83211
|
83217
|
83218