PaperMC/CraftBukkit-Patches/0032-Filter-Invalid-Names.patch

31 lines
1.3 KiB
Diff
Raw Normal View History

2013-09-08 00:36:30 +02:00
From 528a10480647a939af1c9271765c34f2eaa33c8d Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Thu, 25 Jul 2013 17:06:02 +1000
2013-06-21 09:45:10 +02:00
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
2013-09-08 00:36:30 +02:00
index 5593b62..5e9dad2 100644
--- a/src/main/java/net/minecraft/server/PendingConnection.java
+++ b/src/main/java/net/minecraft/server/PendingConnection.java
2013-09-08 00:36:30 +02:00
@@ -66,6 +66,7 @@ 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) {
// CraftBukkit start
2013-09-08 00:36:30 +02:00
if (this.g != null) {
@@ -74,7 +75,7 @@ public class PendingConnection extends Connection {
this.hostname = packet2handshake.c == null ? "" : packet2handshake.c + ':' + packet2handshake.d;
// CraftBukkit end
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