Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-3476

Lowercase options before storing when set via mongoc_uri_set_option_as_*



    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 1.17.0-rc0, 1.17.0
    • libmongoc, uri


      When options are parsed from the connection string passed to mongoc_uri_new, they are internally stored on uri->options after being converted to lowercase in mongoc_uri_split_option here.

      However, options that are set via the mongoc_uri_set_option_as_* are not lowercased before being stored in uri->options.

      For consistency, let's lowercase options before storing them in the mongoc_uri_set_options_as_* functions. This should allow us to remove a lot of case sensitivity checks in URI related functions.

      In addition, there may be a bug caused by the inconsistent casing. Specifying a mongodb+srv URI can result in options being added to a mongoc_uri_t after polling for TXT records in client construction. See the Initial Seedlist Spec for background. TXT records are polled for in mongoc_topology_new here.

      mongoc_uri_options_validate_names, is used to check for canonical/non-canonical mismatches between uri->options and options being added. It appears to assume that both cases of the options are the same. So I think this scenario could be a bug:

      uri = mongoc_uri_new("mongodb+srv://host")
      mongoc_uri_set_option_as_bool (uri, "TLS", true)
      client = mongoc_client_new_from_uri (uri)
      /* TXT record comes back with option ssl=false. mongoc_uri_options_validate_names does not find the conflicting options because it expects TLS to be stored in lowercase. */

      Perhaps adding a test should be a part of this work. We don't have automated SRV tests, but we could simulate the TXT records by calling the private function mongoc_uri_parse_options.


        Issue Links



              andrew.witten@mongodb.com Andrew Witten (Inactive)
              kevin.albertson@mongodb.com Kevin Albertson
              0 Vote for this issue
              3 Start watching this issue