diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index df948e85..4b4e3b4b 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -86,12 +86,23 @@ struct SExecRequestedRule { class CVarList { public: + /* passing 's' as a separator will use std::isspace */ CVarList(const std::string& in, long unsigned int lastArgNo = 0, const char separator = ',') { - std::string curitem = ""; - std::string argZ = in; + std::string curitem = ""; + std::string argZ = in; + const bool SPACESEP = separator == 's'; auto nextItem = [&]() { - auto idx = lastArgNo != 0 && m_vArgs.size() >= lastArgNo - 1 ? std::string::npos : argZ.find_first_of(separator); + auto idx = lastArgNo != 0 && m_vArgs.size() >= lastArgNo - 1 ? std::string::npos : ([&]() -> size_t { + if (!SPACESEP) + return argZ.find_first_of(separator); + + uint64_t pos = -1; + while (!std::isspace(argZ[++pos]) && pos < argZ.length()) + ; + + return pos < argZ.length() ? pos : std::string::npos; + }()); if (idx != std::string::npos) { curitem = argZ.substr(0, idx);