From 4082ed92ed80c57cb499de569631a664107ef05b Mon Sep 17 00:00:00 2001 From: Martin Petersson Date: Tue, 19 Jul 2011 12:42:40 +0200 Subject: QNetworkAccessFileBackend: Add warning for file url without scheme. When the scheme is not set for a file we should accept the url but add a warning. The behaviour will change for Qt5 in which we should no longer accept the url if the scheme is not set. Task-number: QTBUG-17731 Reviewed-by: Markus Goetz --- src/network/access/qnetworkaccessfilebackend.cpp | 5 +++-- tests/auto/qnetworkreply/tst_qnetworkreply.cpp | 7 ++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/network/access/qnetworkaccessfilebackend.cpp b/src/network/access/qnetworkaccessfilebackend.cpp index 42cc2c2..7c4adca 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.isEmpty() && url.authority().isEmpty()) { // 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,7 +75,8 @@ 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()) + // On Windows and Symbian the drive letter is detected as the scheme. + if (fi.exists() && (url.scheme().isEmpty() || (url.scheme().length() == 1))) 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 45f501c..34b0375 100644 --- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp @@ -1672,10 +1672,8 @@ 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 @@ -1691,10 +1689,9 @@ 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("empty-scheme-host", "this is expected to fail, QTBUG-17731", Abort); + 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); -- cgit v0.12