summaryrefslogtreecommitdiff
path: root/src/configparser.cpp
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-08-17 14:54:49 +0100
committerPeter Powell <petpow@saberuk.com>2017-09-03 22:44:33 +0100
commitc0ca5c8d41a71eae4ec132e492b546fa03510871 (patch)
tree9200feea4cb083dad48ee3c167073421b695ff58 /src/configparser.cpp
parente7c829af5941c6a8a303ca75ed9ac47570347e41 (diff)
Add support for length arguments in getString.
Diffstat (limited to 'src/configparser.cpp')
-rw-r--r--src/configparser.cpp14
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;
}