<?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>28663</bug_id>
          
          <creation_ts>2015-05-20 15:21:48 +0000</creation_ts>
          <short_desc>[FO31] Escaping rules in fn:xml-to-json</short_desc>
          <delta_ts>2015-10-16 18:34:10 +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>Functions and Operators 3.1</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></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="Christian Gruen">christian.gruen</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          <cc>abel.braaksma</cc>
    
    <cc>public-qt-comments</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>120386</commentid>
    <comment_count>0</comment_count>
    <who name="Christian Gruen">christian.gruen</who>
    <bug_when>2015-05-20 15:21:48 +0000</bug_when>
    <thetext>1. The handling of quotation marks is covered twice in the string escaping rules:

* [...], and any occurrence of quotation mark (&quot;) is replaced by \&quot;
* [...] any occurrence of quotation mark, backspace [...]

The first rule can probably be dropped? I cannot find it in the XSLT spec. neither.

2. FOJS0007 is to be raised if \u is &quot;not followed by four hexadecimal digits (that is [0-9A-F]{4})&quot;. Maybe a-f (lower case) should be allowed as well?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120597</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-05-29 10:00:59 +0000</bug_when>
    <thetext>I&apos;m finding the rules quite hard to decipher, and I think we can achieve greater clarity by refactoring them as follows:

(1) If the attribute escaped=&quot;true&quot; is present for a string value, or escaped-key=&quot;true&quot; for a key value, then:

(1.a) any valid JSON escape sequence present in the string is copied unchanged to the output,

(1.b) any invalid JSON escape sequence results in a dynamic error [err:FOJS0007].

(1.c) any unescaped occurrence of quotation mark, backspace, form-feed, newline, carriage return, or tab is replaced by \&quot;, \b, \f, \n, \r, or \t respectively, 

(1.d) any other codepoint in the range 1-31 or 127-159 is replaced by an escape in the form \uHHHH where HHHH is the upper-case hexadecimal representation of the codepoint value.

(2) Otherwise (that is, in the absence of the attribute escaped=&quot;true&quot; for a string value, or escaped-key=&quot;true&quot; for a key value):

(2.a) any occurrence of backslash (\) is replaced by \\

(2.b) any occurrence of quotation mark, backspace, form-feed, newline, carriage return, or tab is replaced by \&quot;, \b, \f, \n, \r, or \t respectively, 

(2.c) any other codepoint in the range 1-31 or 127-159 is replaced by an escape in the form \uHHHH where HHHH is the upper-case hexadecimal representation of the codepoint value.

I agree that we should allow lower-case A-F in an escape sequence. At one time I was under the impression JSON did not allow this, but this was because I overlooked an obscure clause in RFC4234 whose effect is that the ABNF &quot;A&quot;|&quot;B&quot;|&quot;C&quot; doesn&apos;t mean what you think it does.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120599</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-05-29 10:15:15 +0000</bug_when>
    <thetext>Changed the title, the question of allowing lower-case a-f is not purely editorial.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>120665</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-06-02 20:19:57 +0000</bug_when>
    <thetext>The change was accepted and has been applied.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123744</commentid>
    <comment_count>4</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2015-10-16 18:34:10 +0000</bug_when>
    <thetext>(just clearing the still-open needinfo request of this bug, and transitioning it to &quot;closed&quot; status)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>