diff options
author | Michael Schuster <michael@schuster.ms> | 2019-09-07 05:18:07 +0300 |
---|---|---|
committer | Michael Schuster <michael@schuster.ms> | 2019-09-07 05:18:07 +0300 |
commit | 67107a4f5d0bce7cf728aef0c4f962ece5f72ed7 (patch) | |
tree | bfdb522cb63ab6905e892ca712765c20b3a32f68 /src/gui/owncloudsetupwizard.cpp | |
parent | 0557d53f5feabb2c6ec3166feb4e715bcbd2043c (diff) |
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 <michael@schuster.ms>
Diffstat (limited to 'src/gui/owncloudsetupwizard.cpp')
-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..2bc4b9967 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 { |