QNetworkAccessFileBackend: Do not accept file url without scheme set.
authorMartin Petersson <martin.petersson@nokia.com>
Tue, 19 Jul 2011 11:57:13 +0000 (13:57 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 19 Jul 2011 13:00:46 +0000 (15:00 +0200)
In Qt 4.8 this generated a warning. For Qt 5 we should no longer
accept file urls without a scheme set. So you should use file://
for local files.

Change-Id: I57789e2b56b712aa4f370aec9437c6febf0d0211
Reviewed-on: http://codereview.qt.nokia.com/1822
Reviewed-by: Markus Goetz
src/network/access/qnetworkaccessfilebackend.cpp
tests/auto/qnetworkreply/tst_qnetworkreply.cpp

index 42cc2c2..6a8f099 100644 (file)
@@ -67,7 +67,7 @@ QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op,
     QUrl url = request.url();
     if (url.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0 || url.isLocalFile()) {
         return new QNetworkAccessFileBackend;
-    } else if (!url.scheme().isEmpty() && url.authority().isEmpty()) {
+    } else if (!url.scheme().isEmpty() && url.authority().isEmpty() && (url.scheme().length() > 1)) {
         // check if QFile could, in theory, open this URL via the file engines
         // it has to be in the format:
         //    prefix:path/to/file
@@ -75,8 +75,6 @@ QNetworkAccessFileBackendFactory::create(QNetworkAccessManager::Operation op,
         //
         // this construct here must match the one below in open()
         QFileInfo fi(url.toString(QUrl::RemoveAuthority | QUrl::RemoveFragment | QUrl::RemoveQuery));
-        if ((url.scheme().length()==1) && fi.exists())
-            qWarning("QNetworkAccessFileBackendFactory: URL has no schema set, use file:// for files");
         if (fi.exists() || (op == QNetworkAccessManager::PutOperation && fi.dir().exists()))
             return new QNetworkAccessFileBackend;
     }
index 528fcc8..1ae7689 100644 (file)
@@ -1673,11 +1673,6 @@ void tst_QNetworkReply::getErrors()
     QFETCH(QString, url);
     QNetworkRequest request(url);
 
-#if defined(Q_OS_WIN) || defined (Q_OS_SYMBIAN)
-    if (qstrcmp(QTest::currentDataTag(), "empty-scheme-host") == 0 && QFileInfo(url).isAbsolute())
-        QTest::ignoreMessage(QtWarningMsg, "QNetworkAccessFileBackendFactory: URL has no schema set, use file:// for files");
-#endif
-
     QNetworkReplyPtr reply = manager.get(request);
     reply->setParent(this);     // we have expect-fails
 
@@ -1692,10 +1687,6 @@ void tst_QNetworkReply::getErrors()
     //qDebug() << reply->errorString();
 
     QFETCH(int, error);
-#if defined(Q_OS_WIN) || defined (Q_OS_SYMBIAN)
-    if (QFileInfo(url).isAbsolute())
-        QEXPECT_FAIL("empty-scheme-host", "this is expected to fail on Windows and Symbian, QTBUG-17731", Abort);
-#endif
     QEXPECT_FAIL("ftp-is-dir", "QFtp cannot provide enough detail", Abort);
     // the line below is not necessary
     QEXPECT_FAIL("ftp-dir-not-readable", "QFtp cannot provide enough detail", Abort);