From 3f4c326bf75e9152d3d8fb90a3649bb0a03ce132 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 8 Jan 2020 09:13:18 +0000 Subject: [PATCH] Bug 14759: Replace Text::Unaccent with Unicode::Normalize As shown in the comments on the bug, it appears that Unicode::Normalize is the most reliable way to strip accents from strings for this use case. Signed-off-by: Jonathan Druart Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson (cherry picked from commit 27de0d61792d46e4fbf8bd8dba2d1d6f0a48c091) Signed-off-by: Lucas Gass (cherry picked from commit 708fd8b4b12a954f80fc4630edef4d6fa1ef5c5e) Signed-off-by: Hayley Mapley --- C4/Installer/PerlDependencies.pm | 5 ----- Koha/Patron.pm | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/C4/Installer/PerlDependencies.pm b/C4/Installer/PerlDependencies.pm index 2225463349..c2e61ce684 100644 --- a/C4/Installer/PerlDependencies.pm +++ b/C4/Installer/PerlDependencies.pm @@ -617,11 +617,6 @@ our $PERL_DEPS = { required => 0, min_ver => '0.40' }, - 'Text::Unaccent' => { - 'usage' => 'Core', - 'required' => '1', - 'min_ver' => '1.08', - }, 'Test::WWW::Mechanize' => { 'usage' => 'Testing suite', 'required' => '0', diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 69cc297652..f78bdff922 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -23,7 +23,7 @@ use Modern::Perl; use Carp; use List::MoreUtils qw( uniq ); use JSON qw( to_json ); -use Text::Unaccent qw( unac_string ); +use Unicode::Normalize; use C4::Accounts; use C4::Context; @@ -1293,14 +1293,14 @@ 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 = NFKD( $userid ); + $userid =~ s/\p{NonspacingMark}//g; $userid .= $offset unless $offset == 0; $self->userid( $userid ); $offset++; } while (! $self->has_valid_userid ); return $self; - } =head2 Internal methods -- 2.39.5