summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2017-03-15 12:03:18 +0100
committerDavid Faure <david.faure@kdab.com>2017-03-20 12:55:36 +0000
commit035e0eafa607217f8110a492a9be7d0718e34907 (patch)
treec1b5edb88abf80969df0bd40faa27410e9a1ac7b /src/corelib/io
parent391e3aeef45efc937979b44c32147206e389a60b (diff)
QUrl::fromUserInput: fix handling of files with a ':' in the name
QUrl::isRelative(str) would be false for such files, so first check for file existence before doing any URL parsing. Change-Id: I51b6229251ad94877ac408b2f8018456d3e10a36 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qurl.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 520ad2e5d3..3df7070557 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -4170,12 +4170,15 @@ QUrl QUrl::fromUserInput(const QString &userInput, const QString &workingDirecto
return url;
}
+ const QFileInfo fileInfo(QDir(workingDirectory), userInput);
+ if (fileInfo.exists()) {
+ return QUrl::fromLocalFile(fileInfo.absoluteFilePath());
+ }
+
QUrl url = QUrl(userInput, QUrl::TolerantMode);
// Check both QUrl::isRelative (to detect full URLs) and QDir::isAbsolutePath (since on Windows drive letters can be interpreted as schemes)
- if (url.isRelative() && !QDir::isAbsolutePath(userInput)) {
- QFileInfo fileInfo(QDir(workingDirectory), userInput);
- if ((options & AssumeLocalFile) || fileInfo.exists())
- return QUrl::fromLocalFile(fileInfo.absoluteFilePath());
+ if ((options & AssumeLocalFile) && url.isRelative() && !QDir::isAbsolutePath(userInput)) {
+ return QUrl::fromLocalFile(fileInfo.absoluteFilePath());
}
return fromUserInput(trimmedString);