From 5dd1d354f86692e4c08cc78f3d9743557103449e Mon Sep 17 00:00:00 2001 From: Matthew I Date: Sun, 2 Sep 2012 16:51:17 -0400 Subject: Enforce stricter world names using a blacklist Blacklisted characters are: / \ --- src/util/string.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/util') 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 @@ -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) -- cgit v1.2.3