-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
5.9.0, 5.10.0, 5.11.0
-
None
-
I have modified tst_QUrl::unc() in tst_qurl.cpp to reproduce the bug:
void tst_QUrl::unc()
\{
QUrl buildUNC;
buildUNC.setScheme(QString::fromLatin1("file"));
buildUNC.setHost(QString::fromLatin1("somehost"));
buildUNC.setPath(QString::fromLatin1("somepath"));
QCOMPARE(buildUNC.toLocalFile(), QString::fromLatin1("//somehost/somepath"));
buildUNC.toEncoded();
QVERIFY(!buildUNC.isEmpty());
QUrl parsedUNC("//somehost/somepath");
QCOMPARE(parsedUNC.toLocalFile(), QString::fromLatin1("//somehost/somepath"));
parsedUNC.toEncoded();
QVERIFY(!parsedUNC.isEmpty());
QUrl parsedUNCURL("file:////somehost/somepath");
QCOMPARE(parsedUNCURL.toLocalFile(), QString::fromLatin1("//somehost/somepath"));
parsedUNCURL.toEncoded();
QVERIFY(!parsedUNCURL.isEmpty());
}I have modified tst_QUrl::unc() in tst_qurl.cpp to reproduce the bug: void tst_QUrl::unc() \{ QUrl buildUNC; buildUNC.setScheme(QString::fromLatin1("file")); buildUNC.setHost(QString::fromLatin1("somehost")); buildUNC.setPath(QString::fromLatin1("somepath")); QCOMPARE(buildUNC.toLocalFile(), QString::fromLatin1("//somehost/somepath")); buildUNC.toEncoded(); QVERIFY(!buildUNC.isEmpty()); QUrl parsedUNC("//somehost/somepath"); QCOMPARE(parsedUNC.toLocalFile(), QString::fromLatin1("//somehost/somepath")); parsedUNC.toEncoded(); QVERIFY(!parsedUNC.isEmpty()); QUrl parsedUNCURL(" file:////somehost/somepath "); QCOMPARE(parsedUNCURL.toLocalFile(), QString::fromLatin1("//somehost/somepath")); parsedUNCURL.toEncoded(); QVERIFY(!parsedUNCURL.isEmpty()); }
When QUrl receives an UNC path (\\somehost\somepath, used for network shares on Windows) it will not parse the path correctly (ie, call setHost).
QUrl::fromLocalFile has some code to handle this case but it's not called from QUrl::QUrl(QString)
Besides the attached tests, the issue shows up when using FolderListModel to browse any network share, as it uses QUrls internally.