diff --git a/main.cpp b/main.cpp index 55c16ff..1472bfe 100644 --- a/main.cpp +++ b/main.cpp @@ -96,8 +96,8 @@ QString getURLFromPositionalOptions(const QCommandLineParser& parser) url.remove(passwordEnd, 1); } - // When connect URL + custom command are supported together, we have to consider the pessimistic case - // of a custom command line like bash -c "%command%" + // If a custom command is used, we have to consider the pessimistic case + // of a command line like bash -c "%command%" // so metacharacters from any common shells must be forbidden. // What we need to accept are domain names and IP addresses. // Also throw in '@' for limited support of the password feature (unv://hunter2@1.2.3.4) diff --git a/qmldownloader.cpp b/qmldownloader.cpp index d201f57..e5bbc87 100644 --- a/qmldownloader.cpp +++ b/qmldownloader.cpp @@ -185,11 +185,21 @@ void QmlDownloader::startGame() StartGame(settings_, connectUrl_, false); } +// Does our version of daemon have -connect-trusted? +static bool haveConnectTrusted(const QString& gameVersion) +{ + // Updater version up to v0.2.0 may set "unknown" as game version if versions.json request fails + if (gameVersion == "unknown") + return false; + // Hacky string comparision, assume we won't go down to 0.9 or up to 0.100 :) + return gameVersion > "0.54.1"; +} + void StartGame(const Settings& settings, const QString& connectUrl, bool failIfWindowsAdmin) { QString gameCommand = Sys::getGameCommand(settings.installPath()); QString commandLine; - if (!connectUrl.isEmpty()) { + if (!connectUrl.isEmpty() && !haveConnectTrusted(settings.currentVersion())) { // Behave for now as the old protocol handler which ignores the custom command commandLine = gameCommand + " -connect " + connectUrl; } else { @@ -197,6 +207,9 @@ void StartGame(const Settings& settings, const QString& connectUrl, bool failIfW if (!commandLine.contains(COMMAND_REGEX)) { commandLine = "%command% " + commandLine; } + if (!connectUrl.isEmpty()) { + gameCommand = gameCommand + " -connect-trusted " + connectUrl; + } commandLine.replace(COMMAND_REGEX, gameCommand); } qDebug() << "Starting game with command line:" << commandLine;