check link before open

This commit is contained in:
Le Tan 2024-07-07 22:51:07 +08:00
parent bed95b1757
commit 3477469b66

View File

@ -27,6 +27,8 @@
#include <QFormLayout>
#include <core/global.h>
#include <widgets/messageboxhelper.h>
#include <widgets/mainwindow.h>
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);
}