[Koha-bugs] [Bug 19721] New: Tabulation in the description of a patron category breaks the patron search. Cause : tabs must be escaped in JSON

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Thu Nov 30 14:44:18 CET 2017


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=19721

            Bug ID: 19721
           Summary: Tabulation in the description of a patron category
                    breaks the patron search. Cause: tabs must be escaped
                    in JSON
 Change sponsored?: ---
           Product: Koha
           Version: master
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P5 - low
         Component: Patrons
          Assignee: koha-bugs at lists.koha-community.org
          Reporter: victor.grousset at biblibre.com
        QA Contact: testopia at bugs.koha-community.org
                CC: gmcharlt at gmail.com, kyle.m.hall at gmail.com

=== Reproduce ===
1. Go to staff: /cgi-bin/koha/admin/categories.pl
2. Edit a category with existing patrons
3. Add a tab in the description
   here is one to copy for convenience: "       "
4. Save the category
5. Go to /cgi-bin/koha/members/members-home.pl
6. Filters → Category → select the just edited one
7. Hit search, just below
8. Then you should see "Processing..."
   As if the request was still running forever

=== Cause ===
In the browser dev tools, we can see that the XRH request to "search" actually
comes back.
The response seems normal.
Except that Firefox warns "SyntaxError: JSON.parse: bad control character in
string literal at line 23 column 29 of the JSON data"
Which points to our tab.
Which invalidates the JSON:
https://stackoverflow.com/questions/19799006/unable-to-parse-tab-in-json-files#19799355

> The whitespace characters are: character tabulation (U+0009), line feed (U+000A), carriage return (U+000D), and space (U+0020).
> Whitespace is not allowed within any token, except that space is allowed in strings.

=== Workaround ===
Remove the tab from the description of the category.
In /cgi-bin/koha/admin/categories.pl
One can use the filter in the table (called search).
And search for a tab "  " to get the "corrupted" ones.


=== Fix ===
It seems that we should escape the tabs (and CRs(\r) and LFs(\n))
Or just get rid of them.

Another question is where?
- Where the category form is processed?
  - early in the upper layers? (when the request just comes)
  - or in the lower layers? (if the category is managed by the ORM)
- In the database itself with a trigger?
- Other ideas?

=== Going further ===
How to find which other bugs like this one might cause hard to diagnose issues?

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are watching all bug changes.


More information about the Koha-bugs mailing list