From 9a85914d4febb3c44bcc79347be65ff188527c51 Mon Sep 17 00:00:00 2001 From: samo_lego <34912839+samolego@users.noreply.github.com> Date: Mon, 2 Nov 2020 09:24:12 +0100 Subject: [PATCH] Including regex check for autologin --- .../simpleauth/mixin/MixinServerLoginNetworkHandler.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerLoginNetworkHandler.java b/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerLoginNetworkHandler.java index a31d868..6fa1ac6 100644 --- a/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerLoginNetworkHandler.java +++ b/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerLoginNetworkHandler.java @@ -16,6 +16,8 @@ import javax.net.ssl.HttpsURLConnection; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import static org.samo_lego.simpleauth.SimpleAuth.*; import static org.samo_lego.simpleauth.utils.SimpleLogger.logError; @@ -78,7 +80,9 @@ public abstract class MixinServerLoginNetworkHandler { if(config.experimental.premiumAutologin) { try { String playername = packet.getProfile().getName().toLowerCase(); - if(playerCacheMap.containsKey(PlayerEntity.getOfflinePlayerUuid(playername).toString())) { + Pattern pattern = Pattern.compile("^[a-z0-9_]{3,16}$"); + Matcher matcher = pattern.matcher(playername); + if(playerCacheMap.containsKey(PlayerEntity.getOfflinePlayerUuid(playername).toString()) || !matcher.matches()) { // Player definitely doesn't have a mojang account this.acceptCrackedPlayer = true;