<< Back to previous view

[DJSON-9] Always escape U+2028 and U+2029 to be nice to broken JSON parsers Created: 28/Apr/13  Updated: 10/Jan/14  Resolved: 02/Aug/13

Status: Closed
Project: data.json
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Enhancement Priority: Minor
Reporter: Tim McCormack Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File 0001-Escape-JS-forbidden-unicode-chars-to-be-nice-to-brok.patch    

 Description   

U+2028 and U+2029 should be treated like \n and, viz, escaped even when *escape-unicode* is false.

A number of JSON parsers (such as ExtJS's) think they can eval JSON in a JS runtime to decode it. This is not true, since JS does not allow U+2028 and U+2029 unescaped in strings:

http://timelessrepo.com/json-isnt-a-javascript-subset

While this is broken behavior, it is also quite common, so escaping these characters uniformly may ease some developer pain and surprise.



 Comments   
Comment by Tim McCormack [ 28/Apr/13 9:46 PM ]

Attached patch.

Comment by Stuart Sierra [ 02/Aug/13 3:25 PM ]

Reimplemented as an additional optional argument on master.

Comment by Stuart Sierra [ 10/Jan/14 11:10 AM ]

Marking old issues as 'closed'

Generated at Tue Sep 23 13:49:07 CDT 2014 using JIRA 4.4#649-r158309.