Settings: Disallow space characters entirely
authorSmallJoker <mk939@ymail.com>
Mon, 10 Jun 2019 16:17:57 +0000 (18:17 +0200)
committersfan5 <sfan5@live.de>
Mon, 10 Jun 2019 16:30:59 +0000 (18:30 +0200)
Lua API:
> Setting names can't contain whitespace or any of ="{}#

src/settings.cpp

index 66c17e12d3c4aa8e56175f72a2b363a71be946c9..876c63e7b2c1ea57019a35a6b57f91be73f9463b 100644 (file)
@@ -69,7 +69,9 @@ Settings & Settings::operator = (const Settings &other)
 bool Settings::checkNameValid(const std::string &name)
 {
        bool valid = name.find_first_of("=\"{}#") == std::string::npos;
-       if (valid) valid = trim(name) == name;
+       if (valid)
+               valid = std::find_if(name.begin(), name.end(), ::isspace) == name.end();
+
        if (!valid) {
                errorstream << "Invalid setting name \"" << name << "\""
                        << std::endl;