Skip to content

Commit 7567702

Browse files
obvEvelouis1706
andauthored
fix: use basegame validation for CustomInfo (#452)
* Validate using basegame * Update EXILED/Exiled.API/Features/Player.cs --------- Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com>
1 parent c577619 commit 7567702

File tree

1 file changed

+2
-30
lines changed

1 file changed

+2
-30
lines changed

EXILED/Exiled.API/Features/Player.cs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -348,37 +348,9 @@ public string CustomInfo
348348
get => ReferenceHub.nicknameSync.Network_customPlayerInfoString;
349349
set
350350
{
351-
// NW Client check.
352-
if (value.Contains<char>('<'))
351+
if (NicknameSync.ValidateCustomInfo(value, out string rejectionText))
353352
{
354-
foreach (string token in value.Split('<'))
355-
{
356-
if (token.StartsWith("/", StringComparison.Ordinal) ||
357-
token.StartsWith("b>", StringComparison.Ordinal) ||
358-
token.StartsWith("i>", StringComparison.Ordinal) ||
359-
token.StartsWith("size=", StringComparison.Ordinal) ||
360-
token.Length is 0)
361-
continue;
362-
363-
if (token.StartsWith("color=", StringComparison.Ordinal))
364-
{
365-
if (token.Length < 14 || token[13] != '>')
366-
Log.Error($"Custom info of player {Nickname} has been REJECTED. \nreason: (Bad text reject) \ntoken: {token} \nInfo: {value}");
367-
else if (!Misc.AllowedColors.ContainsValue(token.Substring(6, 7)))
368-
Log.Error($"Custom info of player {Nickname} has been REJECTED. \nreason: (Bad color reject) \ntoken: {token} \nInfo: {value}");
369-
}
370-
else if (token.StartsWith("#", StringComparison.Ordinal))
371-
{
372-
if (token.Length < 8 || token[7] != '>')
373-
Log.Error($"Custom info of player {Nickname} has been REJECTED. \nreason: (Bad text reject) \ntoken: {token} \nInfo: {value}");
374-
else if (!Misc.AllowedColors.ContainsValue(token.Substring(0, 7)))
375-
Log.Error($"Custom info of player {Nickname} has been REJECTED. \nreason: (Bad color reject) \ntoken: {token} \nInfo: {value}");
376-
}
377-
else
378-
{
379-
Log.Error($"Custom info of player {Nickname} has been REJECTED. \nreason: (Bad color reject) \ntoken: {token} \nInfo: {value}");
380-
}
381-
}
353+
Log.Error($"Could not set CustomInfo for {Nickname}. Reason: {rejectionText}");
382354
}
383355

384356
InfoArea = string.IsNullOrEmpty(value) ? InfoArea & ~PlayerInfoArea.CustomInfo : InfoArea |= PlayerInfoArea.CustomInfo;

0 commit comments

Comments
 (0)