const int src_line;
/** Get the value of an option, using def if it does not exist */
- std::string getString(const std::string& key, const std::string& def = "");
+ std::string getString(const std::string& key, const std::string& def = "", size_t minlen = 0, size_t maxlen = UINT32_MAX);
/** Get the value of an option, using def if it does not exist */
long getInt(const std::string& key, long def = 0, long min = LONG_MIN, long max = LONG_MAX);
/** Get the value of an option, using def if it does not exist */
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;
}
{
ConfigTag* fantasy = ServerInstance->Config->ConfValue("fantasy");
AllowBots = fantasy->getBool("allowbots", false);
- std::string fpre = fantasy->getString("prefix");
- fprefix = fpre.empty() ? "!" : fpre;
+ fprefix = fantasy->getString("prefix", "!", 1, ServerInstance->Config->Limits.MaxLine);
Aliases.clear();
ConfigTagList tags = ServerInstance->Config->ConfTags("alias");
OperPrefixMode(Module* Creator)
: PrefixMode(Creator, "operprefix", 'y', OPERPREFIX_VALUE)
{
- std::string pfx = ServerInstance->Config->ConfValue("operprefix")->getString("prefix", "!");
- prefix = pfx.empty() ? '!' : pfx[0];
+ prefix = ServerInstance->Config->ConfValue("operprefix")->getString("prefix", "!", 1, 1)[0];
levelrequired = INT_MAX;
}
};