diff options
Diffstat (limited to 'src/configparser.cpp')
-rw-r--r-- | src/configparser.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/configparser.cpp b/src/configparser.cpp index 7c03fe58a..86268a132 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -402,10 +402,18 @@ bool ConfigTag::readString(const std::string& key, std::string& value, bool allo return false; } -std::string ConfigTag::getString(const std::string& key, const std::string& def) +std::string ConfigTag::getString(const std::string& key, const std::string& def, size_t minlen, size_t maxlen) { - std::string res = def; - readString(key, res); + std::string res; + if (!readString(key, res)) + return def; + + if (res.length() < minlen || res.length() > maxlen) + { + ServerInstance->Logs->Log("CONFIG", LOG_DEFAULT, "WARNING: The length of <%s:%s> is not between %ld and %ld; value set to %s.", + tag.c_str(), key.c_str(), minlen, maxlen, def.c_str()); + return def; + } return res; } |