diff options
author | Andrew Knight <andrew.knight@digia.com> | 2014-03-18 00:08:49 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-18 07:21:57 +0100 |
commit | 3f7951c04ef474f81eda2134b67c4e4020fe39d1 (patch) | |
tree | db4cb95ef8739f2d97c4e11a25b6dd4979c86b16 /src/qml/qml/qqmlfile.cpp | |
parent | ecd4a9ba23c0c538e73dc4f9e75c4d5361ba4c0e (diff) |
Use QUrl::toLocalFile() when decoding a string URL
Some percent-decoded characters may still be present in the string URL,
so it is best to use QUrl::toLocalFile() to process the string properly.
This also makes some drive handling "magic" obselete as QUrl already
handles this.
This fixes an issue whereby QML apps residing in local paths requiring
percent-encoded characters (or which import local file URLs with
percent-encoded characters) would fail to load, as the path was passed
to the file system engine without fully decoding the URL.
Change-Id: I8ec2b06f0661e0ac7cc9df79d35ec5cee211f672
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlfile.cpp')
-rw-r--r-- | src/qml/qml/qqmlfile.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/qml/qml/qqmlfile.cpp b/src/qml/qml/qqmlfile.cpp index be9b011dda..6728fa10a7 100644 --- a/src/qml/qml/qqmlfile.cpp +++ b/src/qml/qml/qqmlfile.cpp @@ -666,18 +666,13 @@ QString QQmlFile::urlToLocalFileOrQrc(const QUrl& url) static QString toLocalFile(const QString &url) { - if (!url.startsWith(QLatin1String("file://"), Qt::CaseInsensitive)) + const QUrl file(url); + if (!file.isLocalFile()) return QString(); - QString file = url.mid(7); - //XXX TODO: handle windows hostnames: "//servername/path/to/file.txt" - // magic for drives on windows - if (file.length() > 2 && file.at(0) == QLatin1Char('/') && file.at(2) == QLatin1Char(':')) - file.remove(0, 1); - - return file; + return file.toLocalFile(); } /*! |