From af168981be4c7fc7c4fc208c5317425359ca8fb0 Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Wed, 23 Aug 2023 19:51:34 +0200 Subject: [PATCH] CI: Test with ubuntu-latest and newer Qt 5.15 --- .github/workflows/build-linux.yml | 7 +++++++ src/scriptable/scriptable.cpp | 16 +++++++++++++++- src/tests/tests.cpp | 6 +++--- utils/github/install-linux.sh | 2 -- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index a8cb5e1d97..8c19e5a7f4 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -32,6 +32,13 @@ jobs: compiler_package: clang with_qt6: false + - os: ubuntu-latest + buildname: Linux-latest + build_type: Debug + compiler: g++ + compiler_package: g++ + with_qt6: false + - os: ubuntu-latest buildname: Qt 6 build_type: Debug diff --git a/src/scriptable/scriptable.cpp b/src/scriptable/scriptable.cpp index dcb5ef395c..a378c20b18 100644 --- a/src/scriptable/scriptable.cpp +++ b/src/scriptable/scriptable.cpp @@ -291,7 +291,21 @@ struct ScriptValueFactory { const auto variant = value.toVariant(); return variant.toRegularExpression(); #else - const QString pattern = toString(value.property("source")); + QString pattern = toString(value.property("source")); + + // Unescape slash characters in JS regex pattern: \/ -> / + bool escape = false; + for (int i = 0; i < pattern.size(); ++i) { + const QChar &c = pattern[i]; + if (escape && c == '/') { + i -= 1; + pattern.remove(i, 1); + escape = false; + } else { + escape = !escape && c == '\\'; + } + } + return pattern == QStringLiteral("(?:)") ? QRegularExpression() : QRegularExpression(pattern); diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp index 51f9c68715..3d28433787 100644 --- a/src/tests/tests.cpp +++ b/src/tests/tests.cpp @@ -1711,7 +1711,7 @@ void Tests::commandsAddCommandsRegExp() { const QString commands = "[Command]\n" - "Match=^(https?|ftps?)://\n"; + "Match=^(https?|ftps?)://\\\\$\n"; // Ensure there is a basic RegExp support. RUN("/test/", "/test/\n"); @@ -1720,7 +1720,7 @@ void Tests::commandsAddCommandsRegExp() RUN("eval" << "exportCommands(importCommands(arguments[1]))" << "--" << commands, commands); RUN("eval" << "Object.prototype.toString.call(importCommands(arguments[1])[0].re)" << "--" << commands, "[object RegExp]\n"); RUN("eval" << "Object.prototype.toString.call(importCommands(arguments[1])[0].wndre)" << "--" << commands, "[object RegExp]\n"); - RUN("eval" << "importCommands(arguments[1])[0].re" << "--" << commands, "/^(https?|ftps?):\\/\\//\n"); + RUN("eval" << "importCommands(arguments[1])[0].re" << "--" << commands, "/^(https?|ftps?):\\/\\/\\$/\n"); RUN("eval" << "importCommands(arguments[1])[0].wndre" << "--" << commands, "/(?:)/\n"); RUN("eval" << "addCommands(importCommands(arguments[1]))" << "--" << commands, ""); @@ -1728,7 +1728,7 @@ void Tests::commandsAddCommandsRegExp() RUN("exportCommands(commands())", commands); RUN("commands()[0].name", "\n"); - RUN("commands()[0].re", "/^(https?|ftps?):\\/\\//\n"); + RUN("commands()[0].re", "/^(https?|ftps?):\\/\\/\\$/\n"); RUN("commands()[0].wndre", "/(?:)/\n"); } diff --git a/utils/github/install-linux.sh b/utils/github/install-linux.sh index 00ff17ffc1..a85bfa366e 100755 --- a/utils/github/install-linux.sh +++ b/utils/github/install-linux.sh @@ -25,8 +25,6 @@ if [[ $WITH_QT6 == true ]]; then ) else qt_packages=( - qt5-default - qtbase5-private-dev qtdeclarative5-dev qttools5-dev