From 2b149c3d7aa7e2f59fcee6d8778f8e0c685cc406 Mon Sep 17 00:00:00 2001 From: Ere Maijala Date: Wed, 23 Oct 2019 16:23:19 +0300 Subject: [PATCH] Bug 13937: (follow-up) Fix searching with UTF-8 characters. Signed-off-by: Martin Renvoize --- Koha/Z3950Responder/RPN.pm | 1 + t/db_dependent/Koha/Z3950Responder/GenericSession.t | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Koha/Z3950Responder/RPN.pm b/Koha/Z3950Responder/RPN.pm index 403bb78228..a1bfeff7eb 100644 --- a/Koha/Z3950Responder/RPN.pm +++ b/Koha/Z3950Responder/RPN.pm @@ -45,6 +45,7 @@ sub to_koha { my $prefix = ''; my $suffix = ''; my $term = $self->{'term'}; + utf8::decode($term); if ($attrs) { foreach my $attr (@$attrs) { diff --git a/t/db_dependent/Koha/Z3950Responder/GenericSession.t b/t/db_dependent/Koha/Z3950Responder/GenericSession.t index 8fe69704cc..5f0a18d7b1 100644 --- a/t/db_dependent/Koha/Z3950Responder/GenericSession.t +++ b/t/db_dependent/Koha/Z3950Responder/GenericSession.t @@ -1,6 +1,7 @@ #!/usr/bin/perl use Modern::Perl; +use utf8; use Test::More tests => 3; use Test::WWW::Mechanize; @@ -74,7 +75,7 @@ subtest 'test_search' => sub { $search->mock('simple_search_compat', sub { my ( $self, $query ) = @_; - return ('unexpected query', undef, 0) unless $query eq '((author:(author)) AND ((title:(title\(s\))) OR (title:(another))))'; + return ('unexpected query', undef, 0) unless $query eq '((author:(author)) AND ((title:(title\(s\))) OR (title:(speciäl))))'; my @records = ($marc_record_1, $marc_record_2); return (undef, \@records, 2); @@ -103,7 +104,7 @@ subtest 'test_search' => sub { $Zconn->connect('localhost:42111', 0); is($Zconn->errcode(), 0, 'Connection is successful: ' . $Zconn->errmsg()); - my $rs = $Zconn->search_pqf('@and @attr 1=1 @attr 4=1 author @or @attr 1=4 title(s) @attr 1=4 another'); + my $rs = $Zconn->search_pqf('@and @attr 1=1 @attr 4=1 author @or @attr 1=4 title(s) @attr 1=4 speciäl'); is($Zconn->errcode(), 0, 'Search is successful: ' . $Zconn->errmsg()); is($rs->size(), 2, 'Two results returned'); @@ -132,7 +133,7 @@ subtest 'test_search' => sub { @nodes = $dom->getElementsByTagNameNS($ns, 'diagnostics'); is(scalar(@nodes), 1, 'diagnostics returned for bad query'); - $agent->get_ok("$base/biblios?operation=searchRetrieve&recordSchema=marcxml&version=1.1&maximumRecords=10&query=(dc.author%3dauthor AND (dc.title%3d\"title(s)\" OR dc.title%3danother))", 'Retrieve search results'); + $agent->get_ok("$base/biblios?operation=searchRetrieve&recordSchema=marcxml&version=1.1&maximumRecords=10&query=(dc.author%3dauthor AND (dc.title%3d\"title(s)\" OR dc.title%3dspeciäl))", 'Retrieve search results'); $dom = XML::LibXML->load_xml(string => $agent->content()); @nodes = $dom->getElementsByTagNameNS($ns, 'searchRetrieveResponse'); is(scalar(@nodes), 1, 'searchRetrieveResponse returned'); -- 2.39.5