From 67107a4f5d0bce7cf728aef0c4f962ece5f72ed7 Mon Sep 17 00:00:00 2001 From: Michael Schuster Date: Sat, 7 Sep 2019 04:18:07 +0200 Subject: [PATCH 1/2] Fix double slashes in WebDAV URLs (account setup wizard) Sanitize URL paths to elaminate double-slashes in the URL path string, used for the first connection by the account setup wizard. Example: https://cloud.example.com/remote.php/webdav// Signed-off-by: Michael Schuster --- src/gui/owncloudsetupwizard.cpp | 36 ++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index fbe07e8b21..2bc4b9967b 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 elaminate 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 elaminate double-slashes + */ + + EntityExistsJob *job = new EntityExistsJob(_ocWizard->account(), newUrlPath, this); connect(job, &EntityExistsJob::exists, this, &OwncloudSetupWizard::slotRemoteFolderExists); job->start(); } else { From 905c1532fece9d0b50af8decbd872882b64386b5 Mon Sep 17 00:00:00 2001 From: Michael Schuster Date: Wed, 11 Sep 2019 17:31:16 +0200 Subject: [PATCH 2/2] fix comment typo Signed-off-by: Michael Schuster --- src/gui/owncloudsetupwizard.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index 2bc4b9967b..3d20344660 100644 --- a/src/gui/owncloudsetupwizard.cpp +++ b/src/gui/owncloudsetupwizard.cpp @@ -467,7 +467,7 @@ void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders(const QString &localFo } if (nextStep) { /* - * BEGIN - Sanitize URL paths to elaminate double-slashes + * BEGIN - Sanitize URL paths to eliminate double-slashes * * Purpose: Don't rely on unsafe paths, be extra careful. * @@ -497,7 +497,7 @@ void OwncloudSetupWizard::slotCreateLocalAndRemoteFolders(const QString &localFo qCInfo(lcWizard) << "Sanitized to URL path:" << _ocWizard->account()->url().toString() + '/' + newUrlPath; /* - * END - Sanitize URL paths to elaminate double-slashes + * END - Sanitize URL paths to eliminate double-slashes */ EntityExistsJob *job = new EntityExistsJob(_ocWizard->account(), newUrlPath, this);