Uploaded image for project: 'CouchDB'
  1. CouchDB
  2. COUCHDB-333

Json handling of UTF8 strings not in accordance with rfc4627

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.9
    • Fix Version/s: None
    • Component/s: Database Core
    • Labels:
      None
    • Environment:

      couchdb 0.9.0 spidermonkey 0.7.0 erlang R12B3

      Description

      Handling of some unicode values escaped in json format \uXXXX fails with "invalid_json" error.

      curl -X PUT -d '

      {"revisions":[],"_id":"U_1d11e","codepoint":"3441","definition":"\uD834\uDD1E G clef character"}

      ' http://localhost:5984/mydb/U_1d11e

      yields

      {"error":"invalid_json","reason":"

      {\"revisions\":[],\"_id\":\"U_1d11e\",\"codepoint\":\"3441\",\"definition\":\"\\uD834\\uDD1E G clef character\"}

      "}

      When the RFC states:
      To escape an extended character that is not in the Basic Multilingual
      Plane, the character is represented as a twelve-character sequence,
      encoding the UTF-16 surrogate pair. So, for example, a string
      containing only the G clef character (U+1D11E) may be represented as
      "\uD834\uDD1E".

      Furthermore, couchdb accepts encoded strings of the format \uXXXXXXXX which is not mentioned as acceptable in the json rfc

      curl -X PUT -d '

      {"revisions":[],"_id":"U_1d11e","codepoint":"3441","definition":"\u0001D11E G clef character"}

      ' http://localhost:5984/mydb/U_1d11e
      Yields:

      {"ok":true,"id":"U_1d11e","rev":"1-1270273433"}

        Attachments

        1. utf16-surrogate-pairs.diff
          2 kB
          Adam Kocoloski

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                couchmark mark
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: