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