mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-29 20:28:57 +03:00
Merge pull request #1414 from nextcloud/fix-double-slashes
Fix double slashes
This commit is contained in:
commit
d6fce49162
1 changed files with 35 additions and 1 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue