From a7600fa7f7e8e08c63b84ecede559041b1b4b187 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Fri, 19 Jul 2024 19:44:24 +0800 Subject: [PATCH] codesign --remove-signature will cause broken binary (#2530) * codesign --remove-signature will cause broken binary * fix --- .github/workflows/ci-macos.yml | 7 +++++++ src/CPackMacDeployQt.cmake.in | 2 +- src/utils/widgetutils.cpp | 25 ++++++++++++++----------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index ceb9fad06f..87c7d7e892 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -72,6 +72,13 @@ jobs: git clone https://github.com/tamlok/macdeployqtfix.git macdeployqtfix --depth=1 working-directory: ${{runner.workspace}} + - name: Install optool + run: | + wget --no-verbose https://github.com/alexzielenski/optool/releases/download/0.1/optool.zip + unzip ./optool.zip + sudo ln -s ./optool /usr/local/bin/optool + working-directory: ${{runner.workspace}} + - name: Cache Qt id: cache-qt uses: actions/cache@v1 # not v2! diff --git a/src/CPackMacDeployQt.cmake.in b/src/CPackMacDeployQt.cmake.in index 890a1b54fb..b9003ddf08 100644 --- a/src/CPackMacDeployQt.cmake.in +++ b/src/CPackMacDeployQt.cmake.in @@ -1,4 +1,4 @@ -execute_process(COMMAND "codesign" --remove-signature ${CMAKE_CURRENT_BINARY_DIR}/VNote.app +execute_process(COMMAND "optool" strip -t ${CMAKE_CURRENT_BINARY_DIR}/VNote.app WORKING_DIRECTORY ${CPACK_PACKAGE_DIRECTORY} ) execute_process(COMMAND "${MACDEPLOYQT_EXECUTABLE}" ${CMAKE_CURRENT_BINARY_DIR}/VNote.app -dmg diff --git a/src/utils/widgetutils.cpp b/src/utils/widgetutils.cpp index e88a7e6b37..a04e1a2f80 100644 --- a/src/utils/widgetutils.cpp +++ b/src/utils/widgetutils.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -78,19 +79,21 @@ 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; - } + if (scheme == "http" || scheme == "https" || + (p_url.isLocalFile() && QFileInfo(p_url.toLocalFile()).isDir())) { + QDesktopServices::openUrl(p_url); + return; } - QDesktopServices::openUrl(p_url); + // 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; + } } bool WidgetUtils::processKeyEventLikeVi(QWidget *p_widget,