Connecting to a server with a space in the name fails
The bug
Should DNS names be validated to be correct, then remove incorrect characters? Or at least strip whitespace on either side?
How to reproduce
Connect to " x.nerd.nu", you'll get an error about the server not being found.
Potential fix
Easy way to fix in java:
String servername; //assuming we're storing the info from the "Server Address" box into a string servername = servername.trim();
Created Issue:
Connecting to a server with a space in the name fails
Should DNS names be validated to be correct, then remove incorrect characters? Or at least strip whitespace on either side?
Connect to " server.spaceribs.com", you'll get an error about the server not being found.
Environment
Windows
Should DNS names be validated to be correct, then remove incorrect characters? Or at least strip whitespace on either side?
Connect to "
server.spaceribs.com", you'll get an error about the server not being found.Should DNS names be validated to be correct, then remove incorrect characters? Or at least strip whitespace on either side?
Connect to " x.nerd.nu", you'll get an error about the server not being found.
Easy way to fix in java:
String servername; //assuming we're storing the info from the "Server Address" box into a string
servername = servername.trim();
Should DNS names be validated to be correct, then remove incorrect characters? Or at least strip whitespace on either side?
Connect to " x.nerd.nu", you'll get an error about the server not being found.
Easy way to fix in java:
String servername; //assuming we're storing the info from the "Server Address" box into a string
servername = servername.trim();Should DNS names be validated to be correct, then remove incorrect characters? Or at least strip whitespace on either side?
Connect to " x.nerd.nu", you'll get an error about the server not being found.
Easy way to fix in java:
String servername; //assuming we're storing the info from the "Server Address" box into a string servername = servername.trim();
The bug
Should DNS names be validated to be correct, then remove incorrect characters? Or at least strip whitespace on either side?
The bug
Connect to " x.nerd.nu", you'll get an error about the server not being found.
Potential fix
Easy way to fix in java:
String servername; //assuming we're storing the info from the "Server Address" box into a string servername = servername.trim();
Windows
The bug
Should DNS names be validated to be correct, then remove incorrect characters? Or at least strip whitespace on either side?
The bug
Connect to " x.nerd.nu", you'll get an error about the server not being found.
Potential fix
Easy way to fix in java:
String servername; //assuming we're storing the info from the "Server Address" box into a string servername = servername.trim();The bug
Should DNS names be validated to be correct, then remove incorrect characters? Or at least strip whitespace on either side?
How to reproduce
Connect to " x.nerd.nu", you'll get an error about the server not being found.
Potential fix
Easy way to fix in java:
String servername; //assuming we're storing the info from the "Server Address" box into a string servername = servername.trim();
Confirmed:
Perhaps some whitespace stripping and some regular expressions to validate the entry as valid IP/hostname:
ValidIpAddressRegex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"; ValidHostnameRegex = "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$";How is this a bug? " server.spaceribs.com" doesn't exist, so it should not be found.
Its not truly a bug, but could easily be rectified by removing all spaces from the server name string before attempting to connect. Removing the spaces should have no adverse affects as a server name can't have a space in it anyway.
Remember, bug fixes aren't always the result of bugs, sometimes they are just idiot proofing.
But don't forget Darwin:
In any case just trim the String. It's very easy to get a surplus whitespace in when copying an address out of a web browser.
Further checking can be very tricky due to IDNA.
How about showing a warning dialog that informs the user that there is leading space in the address and tell them to remove it</irony>
Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.
Tested on 1.5, still effected (" x.nerd.nu" failed to connect, "x.nerd.nu" is fine). Thanks for the reminder!
Version 1.6.2 is still affected by white space pre or post pended to the server address will prevent it from finding the server.
Confirmed in 14w08a. You may also mention that you are able to add a server to the server list with address " " and nothing more.
Confirmed for 1.10.2. " localhost" results in "cannot resolve hostname" instead of "can't connect to server".
For me it says "Unknown host", which is correct, because there's no server named " localhost". Where is the bug?
Can confirm for MC 1.12.1.
Fabian Röling, when you type in " google.com" in the URL bar of your web browser, your browser won't tell you that the URL is invalid because it omits trailing and leading whitespaces by default. It does that because there are people out there in the vastness of the internet who are very good at making typos. Since whitespaces are invisible, those people probably wouldn't notice it when there was a whitespace at the beginning or at the end of the URL they just typed in and would very likely complain why they can't reach that URL. The same goes for Minecraft servers.
Kumasasa's quote is very fitting here.
Confirmed for 1.13.1.