xNarnia / TCR-TerrariaChatRelay

Self-serving Terraria Chat Relay with extensible chat service support
https://forums.terraria.org/index.php?threads/tcr-terrariachatrelay.78196/
MIT License
32 stars 16 forks source link

Fix System.ArgumentOutOfRangeException if the message is too short. #25

Closed StellarPurr closed 2 years ago

StellarPurr commented 2 years ago

Fix System.ArgumentOutOfRangeException if input.Length < commandPrefix.Length.

xNarnia commented 2 years ago

Thank you for the commit! I'll make sure to review it soon 😊

xNarnia commented 2 years ago

Wow that is a tricky one lol. I hadn't realized that the <= condition wasn't accounted for. We can actually accomplish the same effect by putting these two lines at the top of the method! if (input.Length <= commandPrefix.Length) return false;

I am going to add this change on my end and commit it to the master branch. Thank you for finding this bug and fixing it! It's a huge help 😊

StellarPurr commented 2 years ago

That's awesome! Thank you.

In this case, because the input's length is already checked at the top of the method, so I think we don't need the extra if statement here, right? https://github.com/xPanini/TCR-TerrariaChatRelay/blob/4d18887e5dec22e3ef49264cc3384bf8c721c30a/TCR-TerrariaChatRelay/Command/CommandService.cs#L29