Skip to content

Commit

Permalink
check link before open
Browse files Browse the repository at this point in the history
  • Loading branch information
tamlok committed Jul 7, 2024
1 parent bed95b1 commit 3477469
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/utils/widgetutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include <QFormLayout>

#include <core/global.h>
#include <widgets/messageboxhelper.h>
#include <widgets/mainwindow.h>

using namespace vnotex;

Expand Down Expand Up @@ -75,6 +77,19 @@ QSize WidgetUtils::availableScreenSize(QWidget *p_widget)

void WidgetUtils::openUrlByDesktop(const QUrl &p_url)
{
const auto scheme = p_url.scheme();
if (scheme != "http" && scheme != "https") {
// Prompt for user.
int ret = MessageBoxHelper::questionYesNo(MessageBoxHelper::Warning,
MainWindow::tr("Are you sure to open link (%1)?").arg(p_url.toString()),
MainWindow::tr("Malicious link might do harm to your device."),
QString(),
nullptr);
if (ret == QMessageBox::No) {
return;
}
}

QDesktopServices::openUrl(p_url);
}

Expand Down

0 comments on commit 3477469

Please sign in to comment.