Filter out Unicode and non-printable ASCII

+ return when authentication fails because of null client
This commit is contained in:
juanjp600
2016-08-28 16:01:23 -03:00
parent c51837ef30
commit d909a8d9b6
2 changed files with 15 additions and 1 deletions

View File

@@ -92,8 +92,21 @@ namespace Barotrauma.Networking
{
name = name.Substring(0, 20);
}
string rName = "";
for (int i=0;i<name.Length;i++)
{
if (name[i] < 32 || name[i] > 126)
{
//TODO: allow safe unicode characters, this is just to prevent players from taking names that look similar but aren't the same
rName += '?';
}
else
{
rName += name[i];
}
}
return name;
return rName;
}
public void SetPermissions(ClientPermissions permissions)