From 561e54527bff2102fa7b8782249b20a652c90cf4 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 2 Jun 2021 06:16:27 -0700 Subject: [PATCH] Only use actual regex matches to avoid --- hecl/lib/CVarManager.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hecl/lib/CVarManager.cpp b/hecl/lib/CVarManager.cpp index 4b40544ec..4dbd8aac1 100644 --- a/hecl/lib/CVarManager.cpp +++ b/hecl/lib/CVarManager.cpp @@ -18,7 +18,7 @@ CVar* com_configfile = nullptr; CVar* com_enableCheats = nullptr; CVar* com_cubemaps = nullptr; -static const std::regex cmdLineRegex(R"(\+([\w\.]+)([=])?([\"\/\\\s\w\.\-]+)?)"); +static const std::regex cmdLineRegex(R"(\+([\w\.]+)([=])?([\/\\\s\w\.\-]+)?)"); CVarManager* CVarManager::m_instance = nullptr; static logvisor::Module CVarLog("CVarManager"); @@ -312,9 +312,15 @@ void CVarManager::parseCommandLine(const std::vector& args) { std::string cvarValue; if (std::regex_match(tmp, matches, cmdLineRegex)) { - if (matches.size() == 3) { + std::vector realMatches; + for (auto match : matches) { + if (match.matched) { + realMatches.push_back(match); + } + } + if (realMatches.size() == 2) { cvarName = matches[1].str(); - } else if (matches.size() == 4) { + } else if (realMatches.size() == 4) { cvarName = matches[1].str(); cvarValue = matches[3].str(); }