CelesteNet icon indicating copy to clipboard operation
CelesteNet copied to clipboard

Use `Ordinal` instead of `InvariantCulture` comparison

Open SnipUndercover opened this issue 6 months ago • 0 comments

Invariant culture string comparisons normalize the string, which we don't want. Always use ordinal string comparisons instead; see this article.

Using invariant culture crashes the game when typing /tp tm when a player with the username is connected to the server, as "™".StartsWith("tm", StringComparison.InvariantCultureIgnoreCase) returns true and causes the length on line 1114 to be out of bounds.

https://github.com/0x0ade/CelesteNet/blob/27ac4d76f52f8bbade6e386a6891977f4c059e40/CelesteNet.Client/Components/CelesteNetChatComponent.cs#L1113-L1118

image

SnipUndercover avatar Aug 06 '24 17:08 SnipUndercover