summaryrefslogtreecommitdiff
path: root/src/string.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-07-04 16:36:47 +0000
committerrubidium <rubidium@openttd.org>2013-07-04 16:36:47 +0000
commit4c443bce5cf042265099d5239d8958d2e61a6793 (patch)
tree910e1724668d86722a74d6344279249642b2005b /src/string.cpp
parent76566fde5b92828be695afb14a8307b61d3d9049 (diff)
downloadopenttd-4c443bce5cf042265099d5239d8958d2e61a6793.tar.xz
(svn r25555) -Fix [FS#5632]: [Script] Texts from scripts were not validated before they were shown, causing an assertion to trigger
Diffstat (limited to 'src/string.cpp')
-rw-r--r--src/string.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/string.cpp b/src/string.cpp
index b543ab868..39fc8479c 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -255,6 +255,18 @@ void str_validate(char *str, const char *last, StringValidationSettings settings
}
/**
+ * Scans the string for valid characters and if it finds invalid ones,
+ * replaces them with a question mark '?'.
+ * @param str the string to validate
+ */
+void ValidateString(const char *str)
+{
+ /* We know it is '\0' terminated. */
+ str_validate(const_cast<char *>(str), str + strlen(str) + 1);
+}
+
+
+/**
* Checks whether the given string is valid, i.e. contains only
* valid (printable) characters and is properly terminated.
* @param str The string to validate.