diff --git a/containments/desktop/plugins/folder/foldermodel.cpp b/containments/desktop/plugins/folder/foldermodel.cpp --- a/containments/desktop/plugins/folder/foldermodel.cpp +++ b/containments/desktop/plugins/folder/foldermodel.cpp @@ -341,12 +341,26 @@ QUrl FolderModel::resolve(const QString& url) { + QString processedInput = url; QUrl resolvedUrl; - if (url.startsWith(QLatin1Char('~'))) { - resolvedUrl = QUrl::fromLocalFile(KShell::tildeExpand(url)); + // Strip trailing space if necessary since this will cause QUrl::fromUserInput + // to mangle the path + bool originalPathEndedWithASpace = false; + if (processedInput.endsWith(QLatin1Char(' '))) { + originalPathEndedWithASpace = true; + processedInput.chop(1); + } + + if (processedInput.startsWith(QLatin1Char('~'))) { + resolvedUrl = QUrl::fromLocalFile(KShell::tildeExpand(processedInput)); } else { - resolvedUrl = QUrl::fromUserInput(url); + resolvedUrl = QUrl::fromUserInput(processedInput); + } + + // Re-add the trailing space if necessary + if (originalPathEndedWithASpace) { + resolvedUrl.setPath(resolvedUrl.path() + QLatin1Char(' ')); } return resolvedUrl;