From 5fab555c48f306e080504352f60b903ed02f32ec Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Thu, 7 Mar 2013 18:46:04 +0100 Subject: [PATCH] Real Minecraft username check --- src/Player.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Player.php b/src/Player.php index 6416a47a..d63d8236 100644 --- a/src/Player.php +++ b/src/Player.php @@ -529,10 +529,10 @@ class Player{ break; } $this->loggedIn = true; - $this->username = str_replace(array("\x00", "/", " ", "\r", "\n", '"', "'"), array("", "-", "_", "", "", "", ""), $data["username"]); - $this->iusername = strtolower($this->username); - - if($this->username == ""){ + if(preg_match('#^[a-zA-Z0-9_]{2,16}$#', $data["username"])){ + $this->username = $data["username"]; + $this->iusername = strtolower($this->username); + }else{ $this->close("bad username", false); break; }