Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/gui/guiutility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,19 @@

bool Utility::openBrowser(const QUrl &url, QWidget *errorWidgetParent)
{
if (!url.isValid()) {
qCWarning(lcUtility) << "URL format is invalid and has been rejected:" << url.toString();
return false;
}

const QStringList allowedUrlSchemes = {

Check warning on line 28 in src/gui/guiutility.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/guiutility.cpp:28:23 [cppcoreguidelines-init-variables]

variable 'allowedUrlSchemes' is not initialized
"http",
"https",
};

if (!allowedUrlSchemes.contains(url.scheme())) {
qCWarning(lcUtility) << "URL format is not supported, or it has been compromised for:" << url.toString();

const auto scheme = url.scheme().toLower();
if (!allowedUrlSchemes.contains(scheme)) {

Check warning on line 34 in src/gui/guiutility.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use the init-statement to declare "scheme" inside the if statement.

See more on https://sonarcloud.io/project/issues?id=nextcloud_desktop&issues=AZ2W4NFnOg1JQ0upO4EH&open=AZ2W4NFnOg1JQ0upO4EH&pullRequest=9850
qCWarning(lcUtility) << "URL scheme is not allowed and has been rejected:" << url.toString();
return false;
}

Expand Down
6 changes: 6 additions & 0 deletions src/gui/systray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "configfile.h"
#include "accessmanager.h"
#include "callstatechecker.h"
#include "guiutility.h"

#include <QCursor>
#include <QGuiApplication>
Expand Down Expand Up @@ -69,7 +70,12 @@
_trayEngine->addImageProvider(QLatin1String("tray-image-provider"), new TrayImageProvider);
}

bool Systray::openUrlInBrowser(const QUrl &url) const

Check warning on line 73 in src/gui/systray.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/systray.cpp:73:15 [modernize-use-trailing-return-type]

use a trailing return type for this function
{
return Utility::openBrowser(url);
}

Systray::Systray()

Check warning on line 78 in src/gui/systray.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/systray.cpp:78:1 [cppcoreguidelines-pro-type-member-init]

constructor does not initialize these fields: , , , _trayEngine, _contextMenu, _trayWindow, _callsAlreadyNotified, _editFileLocallyLoadingDialog, _encryptionTokenDiscoveryDialog, _fileDetailDialogs, _fakeActivityModel
: QSystemTrayIcon(nullptr)
{
#if defined(Q_OS_MACOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_14 && defined(BUILD_OWNCLOUD_OSX_BUNDLE)
Expand Down
2 changes: 2 additions & 0 deletions src/gui/systray.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class Systray : public QSystemTrayIcon
void hideSettingsDialog();

public slots:
[[nodiscard]] bool openUrlInBrowser(const QUrl &url) const;

void setTrayEngine(QQmlApplicationEngine *trayEngine);
void create();

Expand Down
2 changes: 1 addition & 1 deletion src/gui/tray/CallNotificationDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ ApplicationWindow {
Layout.preferredHeight: Style.callNotificationPrimaryButtonMinHeight

onClicked: {
Qt.openUrlExternally(modelData.link);
Systray.openUrlInBrowser(modelData.link);
root.closeNotification();
}

Expand Down
2 changes: 1 addition & 1 deletion src/gui/tray/MainWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ ApplicationWindow {

activeFocusOnTab: true
model: activityModel
onOpenFile: Qt.openUrlExternally(filePath);
onOpenFile: Systray.openUrlInBrowser(filePath);
onActivityItemClicked: {
model.slotTriggerDefaultAction(index)
}
Expand Down
Loading