Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-8701

QUrl support for empty but defined authority

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • P4: Low
    • 4.7.1
    • 4.5.2, 4.6.2
    • Network
    • None
    • 884f15e

    Description

      QUrl converts the URL "foo:///bar" to "foo:/bar" when storing it to a QUrl and doing toString(). The "//" after the separator ":" is removed.

      ----------

      The validity of the URL in question:

      According to the RFC 3986, "foo:///bar" is a valid URI. QUrl claims to conform to this specification.

      The validity can be seen by following the following rules:
      URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]
      hier-part = "//" authority path-abempty

      authority = [userinfo "@"] host [":" port]
      host = reg-name
      reg-name = *(unreserved/pct-encoded/sub-delims) <---i.e., reg-name can be an empty string

      path-abempty = *( "/" segment )
      segment = *pchar

      In this case, authority is "", and path is "/bar".

      ----------

      QUrl seems to involve the following logic:

      • the uri is broken down into scheme, authority etc.
      • in toString, the URI is compiled back: first scheme, then ":", after which "//" is inserted in the following cases:
        • authority non-empty
        • scheme == "file"

      According to the RFC, this logic seems wrong: it's possible to have a "://" even with an empty "authority" part. The "file" scheme shouldn't be a special case; it is not listed as a special case in the RFC.

      ----------
      Example code:
      QUrl bug("foo:///bar"); // QUrl::StrictMode doesn't change anything
      qDebug() << bug.toString() << bug.isValid();

      Prints out:
      "foo:/bar" true

      Attachments

        1. qurltests.patch
          0.9 kB
        2. qurlslashissue.cpp
          0.9 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            tmacieir Thiago Macieira (closed Nokia identity) (Inactive)
            marja Marja Hassinen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes