Bugzilla – Attachment 69326 Details for
Bug 19655
To.json doesn't escape newlines which can create invalid JSON
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19655 - To.json doesn't escape newlines which can create invalid JSON
Bug-19655---Tojson-doesnt-escape-newlines-which-ca.patch (text/plain), 1.52 KB, created by
Marcel de Rooy
on 2017-11-24 06:59:39 UTC
(
hide
)
Description:
Bug 19655 - To.json doesn't escape newlines which can create invalid JSON
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-11-24 06:59:39 UTC
Size:
1.52 KB
patch
obsolete
>From 202790a07db3a8eaf0ac2ab3d8cd755c473eb345 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Mon, 20 Nov 2017 11:05:35 -0500 >Subject: [PATCH] Bug 19655 - To.json doesn't escape newlines which can create > invalid JSON >Content-Type: text/plain; charset=utf-8 > >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> >--- > Koha/Template/Plugin/To.pm | 2 ++ > 1 file changed, 2 insertions(+) > >diff --git a/Koha/Template/Plugin/To.pm b/Koha/Template/Plugin/To.pm >index 6bf56b1..f87a39c 100644 >--- a/Koha/Template/Plugin/To.pm >+++ b/Koha/Template/Plugin/To.pm >@@ -29,6 +29,8 @@ sub json { > my $json = JSON->new->allow_nonref(1); > $json = $json->encode($value); > $json =~ s/^"|"$//g; # Remove quotes around the strings >+ $json =~ s/\\r/\\\\r/g; # Convert newlines to escaped newline characters >+ $json =~ s/\\n/\\\\n/g; > return $json; > } > >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19655
:
69235
|
69244
| 69326 |
69346
|
69732
|
69806