summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-11-19 19:38:02 +0000
committerrubidium <rubidium@openttd.org>2010-11-19 19:38:02 +0000
commitede2fb8176f655a1bab693fb421d7f78e524cafe (patch)
treeb1e60bab978e8843dc6d419dc5d98bd082422f8d
parent8ba6d25db6bb99454d91aa12f5cc559f5516397c (diff)
downloadopenttd-ede2fb8176f655a1bab693fb421d7f78e524cafe.tar.xz
(svn r21260) -Codechange: make strgen more stringent w.r.t. the allowed characters in strings
-rw-r--r--src/strgen/strgen.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp
index d7a6ab0f0..f5a95b51e 100644
--- a/src/strgen/strgen.cpp
+++ b/src/strgen/strgen.cpp
@@ -709,6 +709,15 @@ static void HandleString(char *str, bool master)
for (tmp = s; *tmp != '\0';) {
size_t len = Utf8Validate(tmp);
if (len == 0) error("Invalid UTF-8 sequence in '%s'", s);
+
+ WChar c;
+ Utf8Decode(&c, tmp);
+ if (c <= 0x001F || // ASCII control character range
+ (c >= 0xE000 && c <= 0xF8FF) || // Private range
+ (c >= 0xFFF0 && c <= 0xFFFF)) { // Specials range
+ error("Unwanted UTF-8 character U+%04X in sequence '%s'", c, s);
+ }
+
tmp += len;
}