<!-- 
RSS generated by JIRA (4.4#649-r158309) at Thu May 23 15:30:42 CDT 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://dev.clojure.org/jira/si/jira.issueviews:issue-xml/DJSON-3/DJSON-3.xml?field=key&field=summary
-->
<rss version="0.92" >
<channel>
    <title>Clojure JIRA</title>
    <link>http://dev.clojure.org/jira</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>4.4</version>
        <build-number>649</build-number>
        <build-date>25-07-2011</build-date>
    </build-info>

<item>
            <title>[DJSON-3] Error writing strings with characters outside the BMP</title>
                <link>http://dev.clojure.org/jira/browse/DJSON-3</link>
                <project id="10041" key="DJSON">data.json</project>
                        <description>&lt;p&gt;&lt;span class=&quot;error&quot;&gt;&amp;#91;This ticket filed as a follow on from pull request 2 at github&amp;#93;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;One of my users decided to start sending Emoji happy faces over a network protocol encoded using data.json, which caused it to promptly roll over and die. It turned out that write-json-string, while aware of the code point vs. character issue, was still iterating over a character count not a code point count.&lt;/p&gt;

&lt;p&gt;I have demonstrated the problem in a test, and fixed this: will file a patch when my contributor agreement is in place.&lt;/p&gt;</description>
                <environment>Clojure 1.2 and 1.3, Mac OS X, Java 1.6</environment>
            <key id="15078">DJSON-3</key>
            <summary>Error writing strings with characters outside the BMP</summary>
                <type id="1" iconUrl="http://dev.clojure.org/jira/images/icons/bug.gif">Defect</type>
                                <priority id="3" iconUrl="http://dev.clojure.org/jira/images/icons/priority_major.gif">Major</priority>
                    <status id="5" iconUrl="http://dev.clojure.org/jira/images/icons/status_resolved.gif">Resolved</status>
                    <resolution id="1">Completed</resolution>
                                <assignee username="stuart.sierra">Stuart Sierra</assignee>
                                <reporter username="m@mattp.name">Matthew Phillips</reporter>
                        <labels>
                    </labels>
                <created>Fri, 16 Dec 2011 17:53:29 -0600</created>
                <updated>Fri, 9 Mar 2012 19:41:03 -0600</updated>
                    <resolved>Wed, 7 Mar 2012 07:58:48 -0600</resolved>
                                                                    <due></due>
                    <votes>1</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="27510" author="m@mattp.name" created="Thu, 5 Jan 2012 17:57:36 -0600"  >&lt;p&gt;Patch to fix &lt;a href=&quot;http://dev.clojure.org/jira/browse/DJSON-3&quot; title=&quot;Error writing strings with characters outside the BMP&quot;&gt;&lt;del&gt;DJSON-3&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;</comment>
                    <comment id="27555" author="jafingerhut" created="Fri, 13 Jan 2012 01:29:35 -0600"  >&lt;p&gt;I&apos;m not an expert on JSON, so feel free to correct me if I am wrong, but it seems from reading RFC 4627 that strings in JSON, if they are encoded with the \uxxxx format for hex digits xxxx, should have their 16-bit UTF-16 code units encoded in that way.  There should always be exactly 4 hex digits after the \u.&lt;/p&gt;

&lt;p&gt;Here are a couple of test cases with the current code, without either of the patches fix_unicode_non_bmp.patch or fix_unicode_non_bmp_2.patch:&lt;/p&gt;

&lt;p&gt;user=&amp;gt; (in-ns &apos;clojure.data.json)&lt;br/&gt;
#&amp;lt;Namespace clojure.data.json&amp;gt;&lt;/p&gt;

&lt;p&gt;;; Incorrect.&lt;br/&gt;
clojure.data.json=&amp;gt; (map #(format &quot;%x&quot; (int %)) (json-str &quot;abc\ud834\udd1e&quot; :escape-unicode false))&lt;br/&gt;
(&quot;22&quot; &quot;61&quot; &quot;62&quot; &quot;63&quot; &quot;d834&quot; &quot;dd1e&quot; &quot;dd1e&quot; &quot;22&quot;)&lt;/p&gt;

&lt;p&gt;;; Also incorrect.&lt;br/&gt;
clojure.data.json=&amp;gt; (json-str &quot;abc\ud834\udd1e&quot;)&lt;br/&gt;
&quot;\&quot;abc\\u1d11e\\udd1e\&quot;&quot;&lt;/p&gt;


&lt;p&gt;Here is the behavior with patch fix_unicode_non_bmp.patch:&lt;/p&gt;

&lt;p&gt;; This is correct&lt;br/&gt;
clojure.data.json=&amp;gt; (map #(format &quot;%x&quot; (int %)) (json-str &quot;abc\ud834\udd1e&quot; :escape-unicode false))&lt;br/&gt;
(&quot;22&quot; &quot;61&quot; &quot;62&quot; &quot;63&quot; &quot;d834&quot; &quot;dd1e&quot; &quot;22&quot;)&lt;/p&gt;

&lt;p&gt;;; but this is not.  JSON specifies that UTF-16 code units should be&lt;br/&gt;
;; included in string in form \uxxxx, for hex encoding xxxx of 16-bit&lt;br/&gt;
;; code units.&lt;br/&gt;
clojure.data.json=&amp;gt; (json-str &quot;abc\ud834\udd1e&quot;)&lt;br/&gt;
&quot;\&quot;abc\\u1d11e\&quot;&quot;&lt;/p&gt;


&lt;p&gt;Here is the behavior with patch fix_unicode_non_bmp_2.patch:&lt;/p&gt;

&lt;p&gt;;; correct&lt;br/&gt;
clojure.data.json=&amp;gt; (map #(format &quot;%x&quot; (int %)) (json-str &quot;abc\ud834\udd1e&quot; :escape-unicode false))&lt;br/&gt;
(&quot;22&quot; &quot;61&quot; &quot;62&quot; &quot;63&quot; &quot;d834&quot; &quot;dd1e&quot; &quot;22&quot;)&lt;/p&gt;

&lt;p&gt;;; also correct.&lt;br/&gt;
clojure.data.json=&amp;gt; (json-str &quot;abc\ud834\udd1e&quot;)&lt;br/&gt;
&quot;\&quot;abc\\ud834\\udd1e\&quot;&quot;&lt;/p&gt;</comment>
                    <comment id="27562" author="jafingerhut" created="Fri, 13 Jan 2012 15:18:17 -0600"  >&lt;p&gt;fix_unicode_non_bmp_3.patch is same as fix_unicode_non_bmp_2.patch, except it includes the unit test Matthew Phillips had in his patch, plus another one to test the :escape-unicode true case.&lt;/p&gt;</comment>
                    <comment id="27782" author="jafingerhut" created="Mon, 20 Feb 2012 16:03:24 -0600"  >&lt;p&gt;Eventually I may even get the hang of this.  djson-3-non-bmp-chars-patch.txt contains patch in proper format.&lt;/p&gt;</comment>
                    <comment id="27909" author="stuart.sierra" created="Wed, 7 Mar 2012 07:58:48 -0600"  >&lt;p&gt;patch applied.&lt;/p&gt;</comment>
                    <comment id="27916" author="m@mattp.name" created="Thu, 8 Mar 2012 18:39:29 -0600"  >&lt;p&gt;Hi Stuart, it looks like you&apos;ve only applied Andy Fingerhut&apos;s last patch. My fix is in the first one: &quot;fix_unicode_non_bmp.patch&quot;&lt;/p&gt;</comment>
                    <comment id="27930" author="jafingerhut" created="Fri, 9 Mar 2012 11:04:25 -0600"  >&lt;p&gt;Matthew, did you see my comment from Jan 12, 2012?  I show a test case there that appears not to work with your patch, unless I am misunderstanding the correct JSON desired behavior.  That same test does work with my latest patch, I think.  Take a look and see what you think.&lt;/p&gt;</comment>
                    <comment id="27931" author="m@mattp.name" created="Fri, 9 Mar 2012 19:41:03 -0600"  >&lt;p&gt;Oh I see - I misunderstood what your were doing there, thinking it only applied to the escape-unicode == true case.&lt;/p&gt;

&lt;p&gt;And of course the Clojure string is already in UTF-16, so there&apos;s no reason to turn it into 32 bit code points and then expand it back to UTF-16 pairs.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10934" name="djson-3-non-bmp-chars-patch.txt" size="1700" author="jafingerhut" created="Mon, 20 Feb 2012 16:03:24 -0600" />
                    <attachment id="10771" name="fix_unicode_non_bmp_2.patch" size="524" author="jafingerhut" created="Fri, 13 Jan 2012 01:29:35 -0600" />
                    <attachment id="10775" name="fix_unicode_non_bmp_3.patch" size="1279" author="jafingerhut" created="Fri, 13 Jan 2012 15:18:17 -0600" />
                    <attachment id="10759" name="fix_unicode_non_bmp.patch" size="3731" author="m@mattp.name" created="Thu, 5 Jan 2012 17:57:36 -0600" />
                </attachments>
            <subtasks>
        </subtasks>
                <customfields>
                                                                                            <customfield id="customfield_10010" key="com.pyxis.greenhopper.jira:gh-global-rank">
                <customfieldname>Global Rank</customfieldname>
                <customfieldvalues>
                    
                </customfieldvalues>
            </customfield>
                                            <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                <customfieldname>Patch</customfieldname>
                <customfieldvalues>
                        <customfieldvalue key="10002">Code and Test</customfieldvalue>

                </customfieldvalues>
            </customfield>
                                                                                        </customfields>
    </item>
</channel>
</rss>