<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29665</bug_id>
          
          <creation_ts>2016-05-26 10:05:56 +0000</creation_ts>
          <short_desc>[SER31] JSON escaping</short_desc>
          <delta_ts>2016-07-21 18:54:57 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Serialization 3.1</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>https://www.w3.org/XML/Group/qtspecs/specifications/xslt-xquery-serialization-31/html/Overview.html#json-output</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Mills">tim</reporter>
          <assigned_to name="C. M. Sperberg-McQueen">cmsmcq</assigned_to>
          <cc>andrew_coleman</cc>
    
    <cc>mike</cc>
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>126580</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2016-05-26 10:05:56 +0000</bug_when>
    <thetext>The rules for JSON encoding state:

&quot;JSON escaping replaces the characters quotation mark, backspace, form-feed, newline, carriage return, or tab by the corresponding JSON escape sequences \&quot;, \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.&quot;

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 &quot;&lt;/script&gt;&quot; in HTML.

[1] http://andowebsit.es/blog/noteslog.com/post/the-solidus-issue/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126925</commentid>
    <comment_count>1</comment_count>
    <who name="Andrew Coleman">andrew_coleman</who>
    <bug_when>2016-07-08 08:05:52 +0000</bug_when>
    <thetext>The editors agree and propose to revise the above paragraph as follows:

&quot;JSON escaping replaces the characters quotation mark, backspace, form-feed, newline, carriage return, tab, reverse solidus, or solidus by the corresponding JSON escape sequences \&quot;, \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.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126940</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-07-10 09:43:37 +0000</bug_when>
    <thetext>Should the same change (escaping a solidus) be made to the xml-to-json() function?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126965</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2016-07-18 10:17:21 +0000</bug_when>
    <thetext>(In reply to Michael Kay from comment #2)
&gt; Should the same change (escaping a solidus) be made to the xml-to-json()
&gt; function?

Yes.  

I think test case xml-to-json-017 will need to change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127027</commentid>
    <comment_count>4</comment_count>
    <who name="Andrew Coleman">andrew_coleman</who>
    <bug_when>2016-07-21 18:54:57 +0000</bug_when>
    <thetext>At the meeting on 2016-07-19, the WG agreed to adopt the proposal in comment #1.
The changes have now been applied</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>