Server setting for selecting which symbols are allowed in client names. The default setting includes symbols from the character ranges Basic Latin, Latin-1 Supplement, Latin Extended A & B and Cyrillic. Closes #534
This commit is contained in:
@@ -134,17 +134,19 @@ namespace Barotrauma.Networking
|
||||
JobPreferences = new List<JobPrefab>(JobPrefab.List.GetRange(0, Math.Min(JobPrefab.List.Count, 3)));
|
||||
}
|
||||
|
||||
public static bool IsValidName(string name)
|
||||
public static bool IsValidName(string name, GameServer server)
|
||||
{
|
||||
if (name.Contains("\n") || name.Contains("\r")) return false;
|
||||
if (name.Any(c => c == ';' || c == ',' || c == '<' || c == '/')) return false;
|
||||
|
||||
return (name.All(c =>
|
||||
c != ';' &&
|
||||
c != ',' &&
|
||||
c != '<' &&
|
||||
c != '/'));
|
||||
foreach (char character in name)
|
||||
{
|
||||
if (!server.AllowedClientNameChars.Any(charRange => (int)character >= charRange.First && (int)character <= charRange.Second)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static string SanitizeName(string name)
|
||||
{
|
||||
name = name.Trim();
|
||||
@@ -155,16 +157,8 @@ namespace Barotrauma.Networking
|
||||
string rName = "";
|
||||
for (int i = 0; i < name.Length; i++)
|
||||
{
|
||||
if (name[i] < 32)
|
||||
{
|
||||
rName += '?';
|
||||
}
|
||||
else
|
||||
{
|
||||
rName += name[i];
|
||||
}
|
||||
rName += name[i] < 32 ? '?' : name[i];
|
||||
}
|
||||
|
||||
return rName;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user