PaperSpigot-Parent/CraftBukkit-Patches/0033-Filter-Invalid-Names.patch
2013-06-21 17:45:10 +10:00

28 lines
1.2 KiB
Diff

From 47e90e4e5c72a105ff5b9901ef6929ef7511d1fb Mon Sep 17 00:00:00 2001
From: Benjamin James Harrison-Sims <tehrainbowguy@gmail.com>
Date: Sun, 14 Apr 2013 21:19:57 +0500
Subject: [PATCH] Filter Invalid Names
diff --git a/src/main/java/net/minecraft/server/Packet2Handshake.java b/src/main/java/net/minecraft/server/Packet2Handshake.java
index 343af93..26de0b5 100644
--- a/src/main/java/net/minecraft/server/Packet2Handshake.java
+++ b/src/main/java/net/minecraft/server/Packet2Handshake.java
@@ -14,11 +14,13 @@ public class Packet2Handshake extends Packet {
public Packet2Handshake() {}
+ public static final java.util.regex.Pattern validName = java.util.regex.Pattern.compile("^[a-zA-Z0-9_-]{2,16}$");
public void a(DataInputStream datainputstream) throws IOException { // CraftBukkit - throws IOException
this.a = datainputstream.readByte();
this.b = a(datainputstream, 16);
this.c = a(datainputstream, 255);
this.d = datainputstream.readInt();
+ if(!validName.matcher(this.b).matches()) throw new IOException("Invalid name!"); // Spigot
}
public void a(DataOutputStream dataoutputstream) throws IOException { // CraftBukkit - throws IOException
--
1.8.1.2