SQLite

View Ticket
Login
2016-02-04
10:28 Fixed ticket [ad2559db]: JSON does not properly escape control characters plus 5 other changes (artifact: 0134f388 user: drh)
10:28
Escape control characters in JSON. Fix for ticket [ad2559db380abf8]. (check-in: 4f1b5229 user: drh tags: trunk)
10:14 New ticket [ad2559db] JSON does not properly escape control characters. (artifact: 9f98f001 user: drh)

Ticket Hash: ad2559db380abf8e20919136d8ff82267e1f31b3
Title: JSON does not properly escape control characters
Status: Fixed Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2016-02-04 10:28:59
Version Found In: 3.10.2
User Comments:
drh added on 2016-02-04 10:14:04:

The JSON specification requires control characters in strings to be escaped, but the JSON1 extension does not do this. For example:

SELECT json_array(char(1,8,9,10,12,13,31));

The output should be ["\u0001\b\t\n\f\r\u001f"] but the JSON1 extension leaves the characters unescaped.

This error arose because when I was coding up the JSON1 extension I missed the part in the JSON specification that says that control characters must be escaped. I understood the escapes to be optional for all characters other than " and \.