Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use HTTPS if no scheme has been provided in wizard #9621

Merged
merged 1 commit into from
May 4, 2022

Conversation

fmoc
Copy link
Contributor

@fmoc fmoc commented May 2, 2022

No description provided.

@fmoc fmoc requested a review from a team May 2, 2022 15:40
@fmoc fmoc force-pushed the work/wizard-auto-use-https branch from d8c2d27 to 9ca6c1f Compare May 2, 2022 15:47
@sonarcloud
Copy link

sonarcloud bot commented May 2, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

if (QUrl(userProvidedUrl).isRelative() && !userProvidedUrl.isEmpty()) {
userProvidedUrl.prepend(QStringLiteral("https://"));
if (!userProvidedUrl.startsWith(QStringLiteral("http://")) && !userProvidedUrl.startsWith(QStringLiteral("https://"))) {
static const QString defaultScheme(QStringLiteral("https://"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to anonymous namespace.

Remove the qDebug/promise to implement a logging category in an upcoming pr.

What was wrong with

if (QUrl(url).isRelative() && !url.isEmpty()) {

now you will convert foo://bar to https://foo://bar.
Does Qt detect foo:8080 wrong?

Copy link
Contributor Author

@fmoc fmoc May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently, yes. isRelative returns false for me on localhost:9200 at the moment. I first tried to use other QUrl properties, e.g., schema, but schema is set to localhost in this example, whereas host is an empty string then. That makes sense from a technical perspective, since URLs like mailto:a@b.c are legal, too. But from a UX perspective, it makes no sense.

I think we should maintain a list with legal protocols anyway.

We could combine the current check with some QUrl-based ones, e.g.,:

auto url = QUrl::fromUserInput(userProvidedUrl);
if (url.scheme() == "http" || url.scheme() == "https") {...}
if (url.host().isEmpty() && url.scheme() != "http" && url.scheme() != "https") {...}

@fmoc fmoc force-pushed the work/wizard-auto-use-https branch from 9ca6c1f to ddcf9af Compare May 3, 2022 15:24
@@ -33,6 +33,8 @@ QString initLocalFolder()
return OCC::FolderMan::instance()->findGoodPathForNewSyncFolder(localFolder);
}

const QString defaultUrlScheme = QStringLiteral("https://");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move constants to the top of the anonymous namespace.
Historically the constants at least for strings where followed the schema fooC.
The C might have meant CString or constant, I don't care but we should come up with a standard for constants.

I'd suggest to either keep the C or to start Uppercase?

@fmoc fmoc force-pushed the work/wizard-auto-use-https branch from ddcf9af to 4687aab Compare May 4, 2022 14:04
@TheOneRing TheOneRing merged commit 0aa65c5 into master May 4, 2022
@delete-merged-branch delete-merged-branch bot deleted the work/wizard-auto-use-https branch May 4, 2022 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants