(svn r9083) -Codechange: Be more lenient when trimming UTF-8 strings and don't terminate the string when an invalid encoding is encountered, but only focus on maximum length.
authorDarkvater
Sat, 10 Mar 2007 00:26:19 +0000
changeset 6274 40d2a82c6bd6
parent 6273 b692eb6f5754
child 6275 9d330e242010
(svn r9083) -Codechange: Be more lenient when trimming UTF-8 strings and don't terminate the string when an invalid encoding is encountered, but only focus on maximum length.
src/string.cpp
--- a/src/string.cpp	Sat Mar 10 00:25:54 2007 +0000
+++ b/src/string.cpp	Sat Mar 10 00:26:19 2007 +0000
@@ -282,7 +282,8 @@
 
 	for (const char *ptr = strchr(s, '\0'); *s != '\0';) {
 		size_t len = Utf8EncodedCharLen(*s);
-		if (len == 0) break; // invalid encoding
+		/* Silently ignore invalid UTF8 sequences, our only concern trimming */
+		if (len == 0) len = 1;
 
 		/* Take care when a hard cutoff was made for the string and
 		 * the last UTF8 sequence is invalid */