Filter out Unicode and non-printable ASCII
+ return when authentication fails because of null client
This commit is contained in:
@@ -92,8 +92,21 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
name = name.Substring(0, 20);
|
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)
|
public void SetPermissions(ClientPermissions permissions)
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ namespace Barotrauma.Networking
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
inc.SenderConnection.Disconnect("Authentication failed");
|
inc.SenderConnection.Disconnect("Authentication failed");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugConsole.NewMessage("New player has joined the server", Color.White);
|
DebugConsole.NewMessage("New player has joined the server", Color.White);
|
||||||
|
|||||||
Reference in New Issue
Block a user