From 57f5dde7b29dcadacb2644c674597db06a5fe8e7 Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 25 Jul 2013 17:06:02 +1000 Subject: [PATCH] Filter Invalid Names diff --git a/src/main/java/net/minecraft/server/PendingConnection.java b/src/main/java/net/minecraft/server/PendingConnection.java index 8f1c214..d83d475 100644 --- a/src/main/java/net/minecraft/server/PendingConnection.java +++ b/src/main/java/net/minecraft/server/PendingConnection.java @@ -66,13 +66,14 @@ public class PendingConnection extends Connection { } } + private static final java.util.regex.Pattern validName = java.util.regex.Pattern.compile("^[a-zA-Z0-9_-]{2,16}$"); // Spigot public void a(Packet2Handshake packet2handshake) { if (this.g != null) { this.disconnect("Quit repeating yourself!"); } else { this.hostname = packet2handshake.c + ':' + packet2handshake.d; // CraftBukkit - initialize field this.g = packet2handshake.f(); - if (!this.g.equals(StripColor.a(this.g))) { + if (!this.g.equals(StripColor.a(this.g)) || !validName.matcher( this.g ).matches() ) { // Spigot this.disconnect("Invalid username!"); } else { PublicKey publickey = this.server.H().getPublic(); -- 1.8.1.2