diff options
author | David Faure <david.faure@kdab.com> | 2017-02-21 15:08:45 +0100 |
---|---|---|
committer | David Faure <david.faure@kdab.com> | 2017-02-23 18:12:35 +0000 |
commit | 9ffc9e306f639b005dafd67faa122ad0db1b7b86 (patch) | |
tree | d06528cc1a267ec5ec8d58e925a0adc508db19ea /src/corelib/io/qurl.cpp | |
parent | 8cb9314971cdc61137855a6b374b4a4468dff7e7 (diff) |
QUrl::fromUserInput(with cwd) fix handling of files with trailing spaces
The call to trimmed() makes sense for URLs typed in a browser's location bar,
but its use in every code path made it impossible to open a file with a trailing
space in command-line tools that uses fromUserInput(cwd) to handle command-line
arguments, as recommended. For instance kde-open5 "file.txt " would fail.
Change-Id: Ie61182684521d91f077d3e76f95b7240965ab405
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qurl.cpp')
-rw-r--r-- | src/corelib/io/qurl.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 38f2a708b5..520ad2e5d3 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -4170,10 +4170,10 @@ QUrl QUrl::fromUserInput(const QString &userInput, const QString &workingDirecto return url; } - QUrl url = QUrl(trimmedString, QUrl::TolerantMode); + 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(trimmedString)) { - QFileInfo fileInfo(QDir(workingDirectory), trimmedString); + if (url.isRelative() && !QDir::isAbsolutePath(userInput)) { + QFileInfo fileInfo(QDir(workingDirectory), userInput); if ((options & AssumeLocalFile) || fileInfo.exists()) return QUrl::fromLocalFile(fileInfo.absoluteFilePath()); } |