summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Petersson <martin.petersson@nokia.com>2011-07-19 13:57:13 +0200
committerQt by Nokia <qt-info@nokia.com>2011-07-19 15:00:46 +0200
commit9581c90395086932d2e853864bf962b0896597d5 (patch)
treed30bd228b8e5db1fc6da4b9fd7d5b72a1b957255
parentb02bc68066ba5834bca49899ef80cc3dd415809b (diff)
QNetworkAccessFileBackend: Do not accept file url without scheme set.
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
-rw-r--r--src/network/access/qnetworkaccessfilebackend.cpp4
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp9
2 files changed, 1 insertions, 12 deletions
diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp
index 42cc2c2cac..6a8f0993a0 100644
--- a/src/network/access/qnetworkaccessfilebackend.cpp
+++ b/src/network/access/qnetworkaccessfilebackend.cpp
@@ -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;
}
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 528fcc8f90..1ae76899df 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -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);