From a7c9282bf4699d0a73d5e3c7d418c97abd02be31 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 9 Oct 2024 09:46:06 +0800 Subject: [PATCH 1/3] Remove unused import in cmd.cpp Signed-off-by: Claudio Cambra --- src/cmd/cmd.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index 3c940ee2e9adc..c1f71ae8c8cf8 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -15,7 +15,6 @@ */ #include -#include #include #include #include From fc2fb02923ff07dd221e0992da45e839e84ff300 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 9 Oct 2024 09:46:30 +0800 Subject: [PATCH 2/3] Encourage use of https in error message for cmd.cpp Signed-off-by: Claudio Cambra --- src/cmd/cmd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index c1f71ae8c8cf8..b770c3796a8e5 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -347,7 +347,7 @@ int main(int argc, char **argv) if (options.target_url.contains("/webdav", Qt::CaseInsensitive) || options.target_url.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; } From e79e86fde01bb609856902f9175ef43260c9fce7 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Wed, 9 Oct 2024 09:47:03 +0800 Subject: [PATCH 3/3] Properly check for webdav or dav path in provided host url for cmd.cpp Signed-off-by: Claudio Cambra --- src/cmd/cmd.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index b770c3796a8e5..cae496780074f 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -344,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 << "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