Add unit tests

This commit is contained in:
Andrew Steinborn
2018-12-30 03:57:05 -05:00
parent 9ce4294e6e
commit 5bf936d1b9
2 changed files with 40 additions and 2 deletions

View File

@@ -138,8 +138,15 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
}
}
private String cleanVhost(String hostname) {
// Clean out any anything after any zero byte
/**
* Cleans the specified virtual host hostname.
*
* @param hostname the host name to clean
* @return the cleaned hostname
*/
static String cleanVhost(String hostname) {
// Clean out any anything after any zero bytes (this includes BungeeCord forwarding and the
// legacy Forge handshake indicator).
String cleaned = hostname;
int zeroIdx = cleaned.indexOf('\0');
if (zeroIdx > -1) {