summaryrefslogtreecommitdiff
path: root/src/string.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/string.cpp')
-rw-r--r--src/string.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/string.cpp b/src/string.cpp
index 016a4990f..f3ab41623 100644
--- a/src/string.cpp
+++ b/src/string.cpp
@@ -98,7 +98,7 @@ char *CDECL str_fmt(const char *str, ...)
}
-void str_validate(char *str)
+void str_validate(char *str, bool allow_newlines)
{
char *dst = str;
WChar c;
@@ -113,7 +113,14 @@ void str_validate(char *str)
do {
*dst++ = *str++;
} while (--len != 0);
+ } else if (allow_newlines && c == '\n') {
+ *dst++ = *str++;
} else {
+ if (allow_newlines && c == '\r' && str[1] == '\n') {
+ str += len;
+ continue;
+ }
+ assert(c != '\r');
/* Replace the undesirable character with a question mark */
str += len;
*dst++ = '?';