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 Goetzbb10
parent
b02bc68066
commit
9581c90395
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue