Added list of homoglyphs for name comparison
Unicode is now allowed in player names, but it can't be easily exploited anymore
This commit is contained in:
@@ -170,6 +170,7 @@
|
|||||||
<Compile Include="Source\Screens\NetLobbyVoting.cs" />
|
<Compile Include="Source\Screens\NetLobbyVoting.cs" />
|
||||||
<Compile Include="Source\Screens\ServerListScreen.cs" />
|
<Compile Include="Source\Screens\ServerListScreen.cs" />
|
||||||
<Compile Include="Source\Timing.cs" />
|
<Compile Include="Source\Timing.cs" />
|
||||||
|
<Compile Include="Source\Utils\Homoglyphs.cs" />
|
||||||
<Compile Include="Source\Utils\MTRandom.cs" />
|
<Compile Include="Source\Utils\MTRandom.cs" />
|
||||||
<Compile Include="Source\Utils\Rand.cs" />
|
<Compile Include="Source\Utils\Rand.cs" />
|
||||||
<Compile Include="Source\Events\PropertyTask.cs" />
|
<Compile Include="Source\Events\PropertyTask.cs" />
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ namespace Barotrauma.Networking
|
|||||||
c != '<' &&
|
c != '<' &&
|
||||||
c != '/'));
|
c != '/'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string SanitizeName(string name)
|
public static string SanitizeName(string name)
|
||||||
{
|
{
|
||||||
name = name.Trim();
|
name = name.Trim();
|
||||||
@@ -98,9 +98,8 @@ namespace Barotrauma.Networking
|
|||||||
string rName = "";
|
string rName = "";
|
||||||
for (int i=0;i<name.Length;i++)
|
for (int i=0;i<name.Length;i++)
|
||||||
{
|
{
|
||||||
if (name[i] < 32 || name[i] > 126)
|
if (name[i] < 32)
|
||||||
{
|
{
|
||||||
//TODO: allow safe unicode characters, this is just to prevent players from taking names that look similar but aren't the same
|
|
||||||
rName += '?';
|
rName += '?';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ namespace Barotrauma.Networking
|
|||||||
DebugConsole.NewMessage(name + " couldn't join the server (wrong content package hash)", Color.Red);
|
DebugConsole.NewMessage(name + " couldn't join the server (wrong content package hash)", Color.Red);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (connectedClients.Any(c => c.name.ToLower() == name.ToLower() && c.Connection != inc.SenderConnection))
|
else if (connectedClients.Any(c => Homoglyphs.Compare(c.name.ToLower(),name.ToLower()) && c.Connection != inc.SenderConnection))
|
||||||
{
|
{
|
||||||
inc.SenderConnection.Disconnect("The name \"" + name + "\" is already in use. Please choose another name.");
|
inc.SenderConnection.Disconnect("The name \"" + name + "\" is already in use. Please choose another name.");
|
||||||
DebugConsole.NewMessage(name + " couldn't join the server (name already in use)", Color.Red);
|
DebugConsole.NewMessage(name + " couldn't join the server (name already in use)", Color.Red);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user