From d909a8d9b6e9d8a4b26d07e8122cdfa76e385533 Mon Sep 17 00:00:00 2001 From: juanjp600 Date: Sun, 28 Aug 2016 16:01:23 -0300 Subject: [PATCH] Filter out Unicode and non-printable ASCII + return when authentication fails because of null client --- Subsurface/Source/Networking/Client.cs | 15 ++++++++++++++- Subsurface/Source/Networking/GameServerLogin.cs | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Subsurface/Source/Networking/Client.cs b/Subsurface/Source/Networking/Client.cs index 449a7ded8..0b3c17f03 100644 --- a/Subsurface/Source/Networking/Client.cs +++ b/Subsurface/Source/Networking/Client.cs @@ -92,8 +92,21 @@ namespace Barotrauma.Networking { name = name.Substring(0, 20); } + string rName = ""; + for (int i=0;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) diff --git a/Subsurface/Source/Networking/GameServerLogin.cs b/Subsurface/Source/Networking/GameServerLogin.cs index 5b0e54df3..c57d774e9 100644 --- a/Subsurface/Source/Networking/GameServerLogin.cs +++ b/Subsurface/Source/Networking/GameServerLogin.cs @@ -75,6 +75,7 @@ namespace Barotrauma.Networking else { inc.SenderConnection.Disconnect("Authentication failed"); + return; } DebugConsole.NewMessage("New player has joined the server", Color.White);