diff options
author | Michael Schuster <48932272+misch7@users.noreply.github.com> | 2019-09-12 22:25:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-12 22:25:43 +0300 |
commit | d6fce4916248841bf21d9eb5adade6aa5e6368ee (patch) | |
tree | 59081ed92cf58b3245ba74e8714853861139a575 | |
parent | 8f40161fa223a2a8bf53f78fa59a63f7c4e87eeb (diff) | |
parent | f3d774e2e55c2f423af817ae90b9e19191164b30 (diff) |
Merge pull request #1414 from nextcloud/fix-double-slashes
Fix double slashes
-rw-r--r-- | src/gui/owncloudsetupwizard.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index fbe07e8b2..3d2034466 100644 --- a/src/gui/owncloudsetupwizard.cpp +++ b/src/gui/owncloudsetupwizard.cpp @@ -466,7 +466,41 @@ void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders(const QString &localFo _ocWizard->appendToConfigurationLog(res); } if (nextStep) { - EntityExistsJob *job = new EntityExistsJob(_ocWizard->account(), _ocWizard->account()->davPath() + remoteFolder, this); + /* + * BEGIN - Sanitize URL paths to eliminate double-slashes + * + * Purpose: Don't rely on unsafe paths, be extra careful. + * + * Example: https://cloud.example.com/remote.php/webdav// + * + */ + qCInfo(lcWizard) << "Sanitize got URL path:" << QString(_ocWizard->account()->url().toString() + '/' + _ocWizard->account()->davPath() + remoteFolder); + + QString newDavPath = _ocWizard->account()->davPath(), + newRemoteFolder = remoteFolder; + + while (newDavPath.startsWith('/')) { + newDavPath.remove(0, 1); + } + while (newDavPath.endsWith('/')) { + newDavPath.chop(1); + } + + while (newRemoteFolder.startsWith('/')) { + newRemoteFolder.remove(0, 1); + } + while (newRemoteFolder.endsWith('/')) { + newRemoteFolder.chop(1); + } + + QString newUrlPath = newDavPath + '/' + newRemoteFolder; + + qCInfo(lcWizard) << "Sanitized to URL path:" << _ocWizard->account()->url().toString() + '/' + newUrlPath; + /* + * END - Sanitize URL paths to eliminate double-slashes + */ + + EntityExistsJob *job = new EntityExistsJob(_ocWizard->account(), newUrlPath, this); connect(job, &EntityExistsJob::exists, this, &OwncloudSetupWizard::slotRemoteFolderExists); job->start(); } else { |