Bug 19655: Make To.json escape doesn't escape newlines to create valid JSON
authorKyle M Hall <kyle@bywatersolutions.com>
Mon, 20 Nov 2017 16:05:35 +0000 (11:05 -0500)
committerFridolin Somers <fridolin.somers@biblibre.com>
Mon, 11 Dec 2017 08:23:54 +0000 (09:23 +0100)
commitefb28c4af16efbe688322415ae06c6a85fd3454b
treebbbe15c8d7717fcedbc7d8b41d1b959accbe4678
parentf2a828d5519fb346d6e4d768f80e1ebe3f2ead46
Bug 19655: Make To.json escape doesn't escape newlines  to create valid JSON

JSON does not allow real line-breaks. If a field contains them and they are not escaped, a JSON parser will be unable to convert the stringified JSON back into an object.

This is clearly exemplified by the guarantor search, where a multi-line note on the guarantor's record will break the ability to select that guarantor.

Test Plan:
1) Create Patron A with a "Circulation note" that has multiple lines in it
2) Create Patron B
3) Attempt to set Patron A to be the guarantor for Patron B
4) Note selecting the patron does nothing
5) Apply this patch
6) Repeat step 3
7) Selecting the guarantor now works!

Signed-off-by: Simon Pouchol <simon.pouchol@biblibre.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 9cd9240c362336e390eed01acf3630f33e73825f)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Koha/Template/Plugin/To.pm