mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-25 14:36:01 +03:00
Merge pull request #7301 from nextcloud/backport/7286/stable-3.14
[stable-3.14] Properly check for webdav or dav path in provided host url for cmd.cpp
This commit is contained in:
commit
1bdcb33863
1 changed files with 7 additions and 5 deletions
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
#include <qcoreapplication.h>
|
||||
#include <QStringList>
|
||||
#include <QUrl>
|
||||
|
@ -345,15 +344,18 @@ int main(int argc, char **argv)
|
|||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (options.target_url.contains("/webdav", Qt::CaseInsensitive) || options.target_url.contains("/dav", Qt::CaseInsensitive)) {
|
||||
const auto sanitisedTargetUrl = options.target_url.endsWith('/') || options.target_url.endsWith('\\')
|
||||
? options.target_url.chopped(1)
|
||||
: options.target_url;
|
||||
QUrl hostUrl = QUrl::fromUserInput(sanitisedTargetUrl);
|
||||
|
||||
if (const auto hostUrlPath = hostUrl.path(); hostUrlPath.contains("/webdav", Qt::CaseInsensitive) || hostUrlPath.contains("/dav", Qt::CaseInsensitive)) {
|
||||
qWarning("Dav or webdav in server URL.");
|
||||
std::cerr << "Error! Please specify only the base URL of your host with username and password. Example:" << std::endl
|
||||
<< "http(s)://username:password@cloud.example.com" << std::endl;
|
||||
<< "https://username:password@cloud.example.com" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
QUrl hostUrl = QUrl::fromUserInput((options.target_url.endsWith(QLatin1Char('/')) || options.target_url.endsWith(QLatin1Char('\\'))) ? options.target_url.chopped(1) : options.target_url);
|
||||
|
||||
// Order of retrieval attempt (later attempts override earlier ones):
|
||||
// 1. From URL
|
||||
// 2. From options
|
||||
|
|
Loading…
Reference in a new issue