[JAVA-2540] Database name should be checked for validity in connection string Created: 15/Jun/17  Updated: 29/Oct/23  Resolved: 09/Jan/18

Status: Closed
Project: Java Driver
Component/s: Configuration
Affects Version/s: None
Fix Version/s: 3.7.0

Type: New Feature Priority: Major - P3
Reporter: Rathi Gnanasekaran Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by DRIVERS-391 Username and password must be URI-esc... Closed
Duplicate
is duplicated by JAVA-2645 A few connection string specification... Closed

 Description   

Add check for database name validity against the following description, from the connection string specification, of disallowed characters:

The following characters MUST NOT appear in the database name, once it has been decoded: slash, backslash, space, double-quote, or dollar sign.

Because ConnectionString will delegate to MongoNamespace#checkDatabaseNameValidity for this check, and MongoNamespace has to support namespace strings like "$external.$cmd", the Java driver will not prohibit the dollar sign character at this time.



 Comments   
Comment by Githook User [ 09/Jan/18 ]

Author:

{'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}

Message: JAVA-2540: When parsing a connection string, check the validity of the database name.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/19f1938ad55cf42d9be8e49b59426ef821502a52

Comment by Githook User [ 09/Jan/18 ]

Author:

{'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}

Message: JAVA-2540: Further restrict the characters in a database name to also exclude

Comment by Jeffrey Yemin [ 26/Dec/17 ]

The following tests from invalid-uris.json are failing:

    {
      "description": "Username containing an unescaped slash",
      "uri": "mongodb://alice/@localhost/db",
      "valid": false,
      "warning": null,
      "hosts": null,
      "auth": null,
      "options": null
    },
    {
      "description": "Username containing unescaped slash with password",
      "uri": "mongodb://alice/bob:foo@localhost/db",
      "valid": false,
      "warning": null,
      "hosts": null,
      "auth": null,
      "options": null
    },

The failure is because the database name ends up as something like @localhost/db, which the spec now disallows due to the presence of a "/" character. The tests should be fixed and enabled.

Generated at Thu Feb 08 08:57:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.