Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-9311

Update or remove recommended "dollar sign operator escaping" scheme

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • 0.25

    Description

      The following page recommends an ambiguous and harmful escaping scheme: https://docs.mongodb.com/v3.0/faq/developers/#dollar-sign-operator-escaping . People are recommending this escaping scheme based on the fact that its in your documentation, but its a terrible idea. This escaping scheme will break whenever the suggested unicode characters are actually used in the raw key.

      Please either remove this harmful recommendation or update it with a proper unambiguous escaping method. Here's an example that is unambiguous and far more human-readable:

      // returns an escaped mongo key
      exports.escape = function(key)

      { return key.replace(/~/g, '~~') .replace(/\./g, '~,') .replace(/^\$/g, '~$') }

      // returns an unescaped mongo key
      exports.unescape = function(escapedKey)

      { return escapedKey.replace(/^~$/g, '$') .replace(/~,/g, '.') .replace(/~~/g, '~') }

      Attachments

        Activity

          People

            allison.moore@mongodb.com Allison Reinheimer Moore
            fresheneesz Billy Tetrud
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              7 years, 13 weeks, 2 days ago