From 6866339b0c5caf008deff32f3ead117d17ff0b22 Mon Sep 17 00:00:00 2001 From: s1lentq Date: Fri, 25 Dec 2020 19:36:02 +0700 Subject: [PATCH] Host_Say: Fix invalid sequence in UTF-8 --- regamedll/dlls/client.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 3a94f91d..ba813c01 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -806,8 +806,16 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) p[Q_strlen(p) - 1] = '\0'; } + // Check if buffer contains an invalid unicode sequence + // This can happen after truncation up to 127 chars into SV_ParseStringCommand + if (!Q_UnicodeValidate(p)) + { + // Try fix invalid sequence in UTF-8 + Q_UnicodeRepair(p); + } + // make sure the text has content - if (/*!p || */!p[0] || !Q_UnicodeValidate(p)) + if (!p[0]) { // no character found, so say nothing return;