diff --git a/src/scriptable/scriptable.cpp b/src/scriptable/scriptable.cpp index 343222860e..dcb5ef395c 100644 --- a/src/scriptable/scriptable.cpp +++ b/src/scriptable/scriptable.cpp @@ -287,10 +287,15 @@ struct ScriptValueFactory { static QRegularExpression fromScriptValue(const QJSValue &value, const Scriptable *) { if (value.isRegExp()) { +#if QT_VERSION >= QT_VERSION_CHECK(5,15,0) + const auto variant = value.toVariant(); + return variant.toRegularExpression(); +#else const QString pattern = toString(value.property("source")); return pattern == QStringLiteral("(?:)") ? QRegularExpression() : QRegularExpression(pattern); +#endif } if (value.isVariant()) { diff --git a/src/tests/tests.cpp b/src/tests/tests.cpp index efc31cfae9..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=x\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, "/x/\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", "/x/\n"); + RUN("commands()[0].re", "/^(https?|ftps?):\\/\\/\\$/\n"); RUN("commands()[0].wndre", "/(?:)/\n"); }