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

valid_hostname() should not rejects strings with trailing dots

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.16.0
    • Affects Version/s: 1.9.0
    • Component/s: libmongoc, uri

      valid_hostname() rejects strings that start or end with a dot. This method was introduced in a625b39 for CDRIVER-2257. As discussed in mongodb/mongo-php-driver#968, section 3.2.2 of RFC3986 states:

      Such a name consists of a sequence of domain labels separated by ".", each domain label starting and ending with an alphanumeric character and possibly also containing "-" characters. The rightmost domain label of a fully qualified domain name in DNS may be followed by a single "." and should be if it is necessary to distinguish between the complete domain name and some local domain.

      Between this and the grammar definitions in Collected ABNF for URI, it looks like a trailing dot is permitted in a valid host string. I'm not sure if libmongoc is alone in disallowing trailing dots in its valid_hostname() function, which is used for general URI parsing and DNS seedlist discovery (SRV).

      The structure of a hostname not explicitly addressed in the SRV or Connection String specs, but Connection String: Host does reference RFC3986 as the authority on host strings.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: