2013-09-23 08:48:38 +08:00
|
|
|
From af158b963d4d6ed7fd45b5dd918ce3364ec07f7c Mon Sep 17 00:00:00 2001
|
2013-07-25 15:06:35 +08:00
|
|
|
From: md_5 <md_5@live.com.au>
|
|
|
|
Date: Thu, 25 Jul 2013 17:06:02 +1000
|
2013-06-21 15:45:10 +08:00
|
|
|
Subject: [PATCH] Filter Invalid Names
|
2013-06-20 17:44:06 +08:00
|
|
|
|
|
|
|
|
2013-07-25 15:06:35 +08:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PendingConnection.java b/src/main/java/net/minecraft/server/PendingConnection.java
|
2013-09-21 11:39:32 +08:00
|
|
|
index 8f1c214..d83d475 100644
|
2013-07-25 15:06:35 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/PendingConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PendingConnection.java
|
2013-09-21 11:39:32 +08:00
|
|
|
@@ -66,13 +66,14 @@ public class PendingConnection extends Connection {
|
2013-07-25 15:06:35 +08:00
|
|
|
}
|
2013-06-20 17:44:06 +08:00
|
|
|
}
|
|
|
|
|
2013-07-25 15:06:35 +08:00
|
|
|
+ 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) {
|
2013-09-08 06:36:30 +08:00
|
|
|
if (this.g != null) {
|
2013-09-20 09:46:45 +08:00
|
|
|
this.disconnect("Quit repeating yourself!");
|
2013-07-25 15:06:35 +08:00
|
|
|
} else {
|
2013-09-21 11:39:32 +08:00
|
|
|
this.hostname = packet2handshake.c + ':' + packet2handshake.d; // CraftBukkit - initialize field
|
2013-09-20 09:46:45 +08:00
|
|
|
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();
|
2013-06-20 17:44:06 +08:00
|
|
|
--
|
|
|
|
1.8.1.2
|
|
|
|
|