Bug 15722

Summary: Patron search cannot deal with hidden characters ( tabs ) in fields
Product: Koha Reporter: Kyle M Hall <kyle>
Component: PatronsAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: brendan, f.demians, gmcharlt, ian.bays, jonathan.druart, julian.maurice, kyle.m.hall
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 16214    
Attachments: Bug 15722: Escape patron infos for JSON in patron searches
Bug 15722: Escape patron infos for JSON in patron searches
k
[PASSED QA] Bug 15722: Escape patron infos for JSON in patron searches

Description Kyle M Hall 2016-02-02 14:10:06 UTC
The patron search for a library was failing to return and was hung on "processing" what I found was that the patron's email address had a tab and a space at the end. When these were outputted in the json template members/tables/members_results.tt my browser ( chrome ) was unable to process the data giving a syntax error. I found this be recreating the query and calling svc/member/search directly from my browser.
Comment 1 Jonathan Druart 2016-03-08 11:42:01 UTC
Kyle, I don't reproduce:

 update borrowers set email="my@email.com\t " where borrowernumber=42;

Then the results are displayed correctly.
Moreover the email value is not displayed in the table.

Could you detail please?
Comment 2 Kyle M Hall 2016-03-08 12:00:31 UTC
Here is a screencast of me reproducing the issue: http://screencast.com/t/ew0siMJQU

I used Sequel Pro to insert the tab and space.
Comment 3 Ian Bays 2016-03-08 13:14:02 UTC
We have encountered this problem too in data loaded that came with unexpected tabs in the borrower data.  It was very difficult to track down.  Exactly the symptoms seen by Kyle.  No errors that we could see and nothing in the koha error logs that we could find.
Comment 4 Jonathan Druart 2016-03-08 14:13:54 UTC Comment hidden (obsolete)
Comment 5 Kyle M Hall 2016-03-08 15:31:23 UTC Comment hidden (obsolete)
Comment 6 Katrin Fischer 2016-03-24 06:54:51 UTC Comment hidden (obsolete)
Comment 7 Katrin Fischer 2016-03-24 06:55:48 UTC
Created attachment 49518 [details] [review]
[PASSED QA] Bug 15722: Escape patron infos for JSON in patron searches

If patron infos contain invalid JSON chars (\t for instance), the
results won't appear.
The solution is to escape these info.

Test plan:
Edit patron infos in DB (update borrowers set surname="foobar\t" where
borrowernumber=42)
Search for foobar (you should have more than 1 result)
Without this patch, DT retrieves a bad formatted JSON and the results
won't appear.
With this patch, the table result appears

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 8 Brendan Gallagher 2016-03-24 16:15:07 UTC
Pushed to Master - Should be in May 2016 release.  Thanks!
Comment 9 Julian Maurice 2016-04-06 14:17:07 UTC
Note to myself: waiting for bug 16214 to be pushed to master, so I can push them both into 3.22.x at the same time
Comment 10 Julian Maurice 2016-04-07 05:08:19 UTC
Patch pushed to 3.22.x, will be in 3.22.6
Comment 11 Frédéric Demians 2016-04-27 15:39:20 UTC
Pushed to 3.20.x, will be in 3.20.11.