1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-27 17:28:41 +00:00

Enforce stricter world names using a blacklist

Blacklisted characters are: / \
This commit is contained in:
Matthew I 2012-09-02 16:51:17 -04:00 committed by Perttu Ahola
parent a0da6bcf43
commit 5dd1d354f8
4 changed files with 35 additions and 1 deletions

View file

@ -242,6 +242,29 @@ inline bool string_allowed(const std::string &s, const std::string &allowed_char
return true;
}
/*
Checks if a string contains no blacklisted characters (opposite
function of string_allowed())
*/
inline bool string_allowed_blacklist(const std::string & s, const std::string & blacklisted_chars)
{
for(unsigned int i = 0; i < s.length(); i++)
{
bool invalid = false;
for(unsigned int j = 0; j < blacklisted_chars.length(); j++)
{
if(s[i] == blacklisted_chars[j])
{
invalid = true;
break;
}
}
if(invalid)
return false;
}
return true;
}
/*
Forcefully wraps string into rows using \n
(no word wrap, used for showing paths in gui)