Don't allow blank server address

This commit is contained in:
RaphiMC 2024-10-30 22:27:31 +01:00
parent 34fc6c2eaa
commit 1287cb2f9f
No known key found for this signature in database
GPG key ID: 0F6BB0657A03AC94

View file

@ -31,6 +31,10 @@ import java.net.SocketAddress;
public class AddressUtil { public class AddressUtil {
public static SocketAddress parse(final String serverAddress, final ProtocolVersion version) { public static SocketAddress parse(final String serverAddress, final ProtocolVersion version) {
if (serverAddress.isBlank()) {
throw new IllegalArgumentException("Server address cannot be blank");
}
if (serverAddress.startsWith("file:///") || serverAddress.startsWith("unix:///")) { // Unix Socket if (serverAddress.startsWith("file:///") || serverAddress.startsWith("unix:///")) { // Unix Socket
final String filePath = serverAddress.substring(7); final String filePath = serverAddress.substring(7);