-
-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ip adress sanitization for MP Menu screen #196
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, as an embedded dev I understand your approach completely, but this is not the C# way :)
I have suggested a better alternative
@@ -171,6 +171,18 @@ private static void OnJoinGameButtonClick() | |||
string ip = parts[0]; | |||
int port; | |||
|
|||
//remove copy and paste mistakes and update the textbox to prevent user confusion in case of invalid ip address | |||
ip = SanitizeIpAddressString(ip); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using String.Trim()
is probably better than a new function here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trim is identical to Trim(whitespace)
@@ -171,6 +171,18 @@ private static void OnJoinGameButtonClick() | |||
string ip = parts[0]; | |||
int port; | |||
|
|||
//remove copy and paste mistakes and update the textbox to prevent user confusion in case of invalid ip address | |||
ip = ip.Trim('\r', '\n', '\t', ' '); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are all already considered whitespace by c#
After being annoyed by Copy&Paste errors when copying from Discord i figured I could add this as an entry exercise.
Maybe this is a good idea to prevent A) Crashes on invalid IPs and B) Give at least a little feedback about IPv4 only.
Please let me know if this is useable for the project, I am usually a C++ dev.