Bug 15818 - OPAC search with utf-8 characters and without results generates encoding error
Summary: OPAC search with utf-8 characters and without results generates encoding error
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: Main
Hardware: All All
: P5 - low major (vote)
Assignee: Dobrica Pavlinusic
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on: 11944
Blocks:
  Show dependency treegraph
 
Reported: 2016-02-15 14:07 UTC by Dobrica Pavlinusic
Modified: 2019-06-27 09:24 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 15818 - OPAC search with utf-8 characters and without results generates encoding error (1.46 KB, patch)
2016-02-15 14:34 UTC, Dobrica Pavlinusic
Details | Diff | Splinter Review
Bug 15818 - OPAC search with utf-8 characters and without results generates encoding error (1.68 KB, patch)
2016-02-15 15:34 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 15818 - OPAC search with utf-8 characters and without results generates encoding error (1.90 KB, patch)
2016-02-19 09:34 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Dobrica Pavlinusic 2016-02-15 14:07:07 UTC
When searching for something in OPAC which doesn't result in any results we get following encoding error:

Cannot decode string with wide characters at /usr/lib/i386-linux-gnu/perl5/5.20/Encode.pm line 215.
Comment 1 Dobrica Pavlinusic 2016-02-15 14:34:40 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2016-02-15 15:34:13 UTC Comment hidden (obsolete)
Comment 3 Dobrica Pavlinusic 2016-02-17 14:25:47 UTC
Jonathan, I'm wondering do you have libencode-perl package installed or are you using Encode which ships with perl (and which version?).
Comment 4 Jonathan Druart 2016-02-17 15:17:19 UTC
% dpkg -l | grep libencode-perl

Does not return anything and 

% pmpath Encode
/usr/lib/i386-linux-gnu/perl/5.20/Encode.pm
% pmvers Encode
2.60
Comment 5 Dobrica Pavlinusic 2016-02-18 13:22:20 UTC
Interesting. I have libencode-perl which is 2.63 and I do get application error. I guess that built-in Encode is less strict, but anyway, this patch helps :-)
Comment 6 Marcel de Rooy 2016-02-19 09:27:44 UTC
Cannot reproduce this with Encode 2.42
Comment 7 Marcel de Rooy 2016-02-19 09:34:15 UTC
Created attachment 48225 [details] [review]
Bug 15818 - OPAC search with utf-8 characters and without results generates encoding error

When searching for something in OPAC which doesn't result in any results but have utf-8
characters in search string we get following encoding error:

Cannot decode string with wide characters at /usr/lib/i386-linux-gnu/perl5/5.20/Encode.pm line 215.

This is because we are trying to decode string which is allready correctly
marked as utf-8.

Test scenario:

1) enter search string with utf-8 characters in opac which doesn't
   return any results
2) verify that you get application error
3) apply this patch
4) re-run query and verify that errror is gone

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Step 0: Define "OPACNoResultsFound" with '{QUERY_KW}'
Note that I don't get the error (Encode 2.60) but the search terms are
not display correctly.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
The variable to be decoded comes from already decoded vars (via
the -utf8 flag from CGI), following the trail in Search.pm.
Comment 8 Brendan Gallagher 2016-02-22 20:29:31 UTC
pushed to master - should be in the may 2016 release.  thanks!
Comment 9 Julian Maurice 2016-02-26 10:06:15 UTC
Patch pushed to 3.22.x, will be in 3.22.4
Comment 10 Frédéric Demians 2016-03-01 15:23:06 UTC
This patch has been pushed to 3.20.x, will be in 3.20.8.