Skip to content

Commit

Permalink
Use QStringLiteral instead of plain strings
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
  • Loading branch information
Felix Weilbach authored and mgallien committed Jul 21, 2021
1 parent ee49a7e commit 3f6bb4a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/gui/creds/flow2auth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void Flow2Auth::fetchNewToken(const TokenAction action)

// Step 1: Initiate a login, do an anonymous POST request
QUrl url = Utility::concatUrlPath(_account->url().toString(), QLatin1String("/index.php/login/v2"));
_enforceHttps = url.scheme() == "https";
_enforceHttps = url.scheme() == QStringLiteral("https");

// add 'Content-Length: 0' header (see https://github.com/nextcloud/desktop/issues/1473)
QNetworkRequest req;
Expand All @@ -99,7 +99,7 @@ void Flow2Auth::fetchNewToken(const TokenAction action)
&& !json.isEmpty()) {
pollToken = json.value("poll").toObject().value("token").toString();
pollEndpoint = json.value("poll").toObject().value("endpoint").toString();
if (_enforceHttps && QUrl(pollEndpoint).scheme() != "https") {
if (_enforceHttps && QUrl(pollEndpoint).scheme() != QStringLiteral("https")) {
qCWarning(lcFlow2auth) << "Can not poll endpoint because the returned url" << _pollEndpoint << "does not start with https";
emit result(Error, tr("The polling URL does not start with https despite the login URL started with https. Login will not be possible because this might be a security issue. Please contact your administrator."));
return;
Expand Down Expand Up @@ -206,7 +206,7 @@ void Flow2Auth::slotPollTimerTimeout()
if (reply->error() == QNetworkReply::NoError && jsonParseError.error == QJsonParseError::NoError
&& !json.isEmpty()) {
serverUrl = json["server"].toString();
if (_enforceHttps && serverUrl.scheme() != "https") {
if (_enforceHttps && serverUrl.scheme() != QStringLiteral("https")) {
qCWarning(lcFlow2auth) << "Returned server url" << serverUrl << "does not start with https";
emit result(Error, tr("The returned server URL does not start with https despite the login URL started with https. Login will not be possible because this might be a security issue. Please contact your administrator."));
return;
Expand Down
4 changes: 2 additions & 2 deletions src/gui/wizard/webview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ QWebEnginePage * WebEnginePage::createWindow(QWebEnginePage::WebWindowType type)
void WebEnginePage::setUrl(const QUrl &url)
{
QWebEnginePage::setUrl(url);
_enforceHttps = url.scheme() == "https";
_enforceHttps = url.scheme() == QStringLiteral("https");
}

bool WebEnginePage::certificateError(const QWebEngineCertificateError &certificateError)
Expand All @@ -220,7 +220,7 @@ bool WebEnginePage::certificateError(const QWebEngineCertificateError &certifica

bool WebEnginePage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType /*type*/, bool /*isMainFrame*/)
{
if (_enforceHttps && url.scheme() != "https") {
if (_enforceHttps && url.scheme() != QStringLiteral("https")) {
QMessageBox::warning(nullptr, "Security warning", "Can not follow non https link on a https website. This might be a security issue. Please contact your administrator");
return false;
}
Expand Down

0 comments on commit 3f6bb4a

Please sign in to comment.