Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-325

MongoDatabase.ValidateDatabaseName() check for invalid characters is too soft.

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • 1.3
    • 1.2
    • None
    • None
    • Fully Compatible

    Description

      That is what it uses as invalid characters:
      if (name.IndexOfAny(new char[]

      { '\0', ' ', '.', '$', '/', '\\' }

      ) != -1) { ...

      Apparently this is not enough. For example it allowed me to create a database "*" and even add a collection and some data. Nothing was found on my disk, indeed, and no exceptions were thrown.

      As far as database names are used as parts of file system names, more characters should be added to invalid. Perhaps System.IO.Path.GetInvalidFileNameChars() is too much but at least some of them like <>?*|": are candidates.

      Attachments

        Activity

          People

            robert@mongodb.com Robert Stam
            nightroman Roman Kuzmin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: