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

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

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.3
    • Affects Version/s: 1.2
    • Component/s: None
    • None
    • Fully Compatible

      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.

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

              Created:
              Updated:
              Resolved: