diff options
author | Matthew I <matttpt@gmail.com> | 2012-09-02 16:51:17 -0400 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-09-05 01:17:28 +0300 |
commit | 5dd1d354f86692e4c08cc78f3d9743557103449e (patch) | |
tree | 1668bdb85e11e7c5faa93a8c59b47a828e4eadad /src/util | |
parent | a0da6bcf43d71d22b949ccf1e68153b51da53e39 (diff) | |
download | minetest-5dd1d354f86692e4c08cc78f3d9743557103449e.tar.gz minetest-5dd1d354f86692e4c08cc78f3d9743557103449e.tar.bz2 minetest-5dd1d354f86692e4c08cc78f3d9743557103449e.zip |
Enforce stricter world names using a blacklist
Blacklisted characters are: / \
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/string.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/util/string.h b/src/util/string.h index 97b07f2ff..71b11de3d 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -243,6 +243,29 @@ inline bool string_allowed(const std::string &s, const std::string &allowed_char } /* + 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) */ |