Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-55450

JSON.stringify in Realm function does not encode correctly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker - P1
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Operating System:
      ALL
    • Steps To Reproduce:
      Hide

      What I did:

      Configure a Trigger function on a collection and log a property from a document:

      {{exports = async (changeEvent) => { }}{{console.log(JSON.stringify(changeEvent && changeEvent.fullDocument && changeEvent.fullDocument.name)) }}}

       Create a document with a curly brace in the `name` property, e.g. `{ "name": "Test’s" }`

      View the log entry for the create.

      What I expected:

      The log entry would show `Test’s`

      What actually happened:

      The log entry shows `Testâs`

      Additional notes:

      An example log entry is from our trigger named `fanx_data_legacy_dev` with the id `605a194e3684e76b32b532dd`.

      This is not limited to the `console.log` output: our trigger function pushes the JSON.stringify'd document to SQS, and the encoding shows the incorrect `Testâs` as well.

      Show
      What I did: Configure a Trigger function on a collection and log a property from a document: {{exports = async (changeEvent) => { }}{{console.log(JSON.stringify(changeEvent && changeEvent.fullDocument && changeEvent.fullDocument.name)) }}}  Create a document with a curly brace in the `name` property, e.g. `{ "name": "Test’s" }` View the log entry for the create. What I expected: The log entry would show `Test’s` What actually happened: The log entry shows `Testâs` Additional notes: An example log entry is from our trigger named `fanx_data_legacy_dev` with the id `605a194e3684e76b32b532dd`. This is not limited to the `console.log` output: our trigger function pushes the JSON.stringify'd document to SQS, and the encoding shows the incorrect `Testâs` as well.

      Description

      When I use JSON.stringify on an object containing the curly quote character, e.g. `’`, in a triggered function, it is encoded to `â`.

      This is affecting our very high visibility clients in the sport industry, e.g. the NCAA and others.

        Attachments

          Activity

            People

            Assignee:
            eric.sedor Eric Sedor
            Reporter:
            developers@panda.industries Timmy Pandahouse
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: