From 3477469b669708ff547037fda9fc2817870428aa Mon Sep 17 00:00:00 2001 From: Le Tan Date: Sun, 7 Jul 2024 22:51:07 +0800 Subject: [PATCH] check link before open --- src/utils/widgetutils.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/utils/widgetutils.cpp b/src/utils/widgetutils.cpp index b9974b1e8b..e88a7e6b37 100644 --- a/src/utils/widgetutils.cpp +++ b/src/utils/widgetutils.cpp @@ -27,6 +27,8 @@ #include #include +#include +#include using namespace vnotex; @@ -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); }