This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 29665 - [SER31] JSON escaping
Summary: [SER31] JSON escaping
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Serialization 3.1 (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: C. M. Sperberg-McQueen
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL: https://www.w3.org/XML/Group/qtspecs/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-26 10:05 UTC by Tim Mills
Modified: 2016-07-21 18:54 UTC (History)
2 users (show)

See Also:


Attachments

Description Tim Mills 2016-05-26 10:05:56 UTC
The rules for JSON encoding state:

"JSON escaping replaces the characters quotation mark, backspace, form-feed, newline, carriage return, or tab by the corresponding JSON escape sequences \", \b, \f, \n, \r, or \t respectively, and any other codepoint in the range 1-31 or 127-159 by an escape in the form \uHHHH where HHHH is the hexadecimal representation of the codepoint value. Escaping is also applied to any characters that cannot be represented in the selected encoding."

This appears to omit the escaping of reverse-solidus (codepoint 92) as \\.

It also omits the escaping of solidus (character 47).  Reading up on the subject [1], it appears it is advisable to escape this character so that it is safe to embed the JSON substring "</script>" in HTML.

[1] http://andowebsit.es/blog/noteslog.com/post/the-solidus-issue/
Comment 1 Andrew Coleman 2016-07-08 08:05:52 UTC
The editors agree and propose to revise the above paragraph as follows:

"JSON escaping replaces the characters quotation mark, backspace, form-feed, newline, carriage return, tab, reverse solidus, or solidus by the corresponding JSON escape sequences \", \b, \f, \n, \r, \t, \\, or \/ respectively, and any other codepoint in the range 1-31 or 127-159 by an escape in the form \uHHHH where HHHH is the hexadecimal representation of the codepoint value. Escaping is also applied to any characters that cannot be represented in the selected encoding."
Comment 2 Michael Kay 2016-07-10 09:43:37 UTC
Should the same change (escaping a solidus) be made to the xml-to-json() function?
Comment 3 Tim Mills 2016-07-18 10:17:21 UTC
(In reply to Michael Kay from comment #2)
> Should the same change (escaping a solidus) be made to the xml-to-json()
> function?

Yes.  

I think test case xml-to-json-017 will need to change.
Comment 4 Andrew Coleman 2016-07-21 18:54:57 UTC
At the meeting on 2016-07-19, the WG agreed to adopt the proposal in comment #1.
The changes have now been applied