geforkt von Mirrors/Velocity
Improve HandshakeSessionHandler#cleanVhost()
Dieser Commit ist enthalten in:
Ursprung
6eb6c99fa7
Commit
7d4d81fff1
@ -139,7 +139,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
// If we connect through an SRV record, there will be a period at the end (DNS usually elides
|
// If we connect through an SRV record, there will be a period at the end (DNS usually elides
|
||||||
// this ending octet).
|
// this ending octet).
|
||||||
if (cleaned.endsWith(".")) {
|
if (!cleaned.isEmpty() && cleaned.charAt(cleaned.length() - 1) == '.') {
|
||||||
cleaned = cleaned.substring(0, cleaned.length() - 1);
|
cleaned = cleaned.substring(0, cleaned.length() - 1);
|
||||||
}
|
}
|
||||||
return cleaned;
|
return cleaned;
|
||||||
|
@ -11,20 +11,32 @@ class HandshakeSessionHandlerTest {
|
|||||||
@Test
|
@Test
|
||||||
void cleanVhostHandlesGoodHostname() {
|
void cleanVhostHandlesGoodHostname() {
|
||||||
assertEquals("localhost", cleanVhost("localhost"));
|
assertEquals("localhost", cleanVhost("localhost"));
|
||||||
|
assertEquals("mc.example.com", cleanVhost("mc.example.com"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void cleanVhostHandlesTrailingOctet() {
|
void cleanVhostHandlesTrailingOctet() {
|
||||||
assertEquals("localhost", cleanVhost("localhost."));
|
assertEquals("localhost", cleanVhost("localhost."));
|
||||||
|
assertEquals("mc.example.com", cleanVhost("mc.example.com."));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void cleanVhostHandlesForge() {
|
void cleanVhostHandlesForge() {
|
||||||
assertEquals("localhost", cleanVhost("localhost" + HANDSHAKE_HOSTNAME_TOKEN));
|
assertEquals("localhost", cleanVhost("localhost" + HANDSHAKE_HOSTNAME_TOKEN));
|
||||||
|
assertEquals("mc.example.com", cleanVhost("mc.example.com" + HANDSHAKE_HOSTNAME_TOKEN));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void cleanVhostHandlesOctetsAndForge() {
|
void cleanVhostHandlesOctetsAndForge() {
|
||||||
assertEquals("localhost", cleanVhost("localhost." + HANDSHAKE_HOSTNAME_TOKEN));
|
assertEquals("localhost", cleanVhost("localhost." + HANDSHAKE_HOSTNAME_TOKEN));
|
||||||
|
assertEquals("mc.example.com", cleanVhost("mc.example.com." + HANDSHAKE_HOSTNAME_TOKEN));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void cleanVhostHandlesEmptyHostnames() {
|
||||||
|
assertEquals("", cleanVhost(""));
|
||||||
|
assertEquals("", cleanVhost(HANDSHAKE_HOSTNAME_TOKEN));
|
||||||
|
assertEquals("", cleanVhost("."));
|
||||||
|
assertEquals("", cleanVhost("." + HANDSHAKE_HOSTNAME_TOKEN));
|
||||||
}
|
}
|
||||||
}
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren