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

Update or remove recommended "dollar sign operator escaping" scheme

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • # Replies:
      1
    • Last comment by Customer:
      true
    • Story Points:
      0.25
    • Sprint:
      KANBAN BUCKET

      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

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                3 years, 3 weeks, 3 days ago
                Date of 1st Reply: