Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Credits by Bian from L2jBrasil
- ### Eclipse Workspace Patch 1.0
- #P L2jFrozen_GameServer
- Index: head-src/com/l2jfrozen/loginserver/LoginController.java
- ===================================================================
- --- head-src/com/l2jfrozen/loginserver/LoginController.java (revision 1118)
- +++ head-src/com/l2jfrozen/loginserver/LoginController.java (working copy)
- @@ -32,6 +32,9 @@
- import java.sql.ResultSet;
- import java.util.Collection;
- import java.util.Map;
- +import java.util.regex.Matcher;
- +import java.util.regex.Pattern;
- +import java.util.regex.PatternSyntaxException;
- import javax.crypto.Cipher;
- @@ -650,6 +653,9 @@
- // LOGGER it anyway
- Log.add("'" + (user == null ? "null" : user) + "' " + (address == null ? "null" : address.getHostAddress()), "logins_ip");
- + if (!isValidLogin(user))
- + return false;
- +
- // player disconnected meanwhile
- if (address == null)
- return false;
- @@ -972,4 +978,25 @@
- }
- }
- }
- +
- + public static boolean isValidLogin(String text)
- + {
- + return isValidPattern(text, "^[A-Za-z0-9]{1,16}$");
- + }
- +
- + public static boolean isValidPattern(String text, String regex)
- + {
- + Pattern pattern;
- +
- + try
- + {
- + pattern = Pattern.compile(regex);
- + }
- + catch (PatternSyntaxException e)
- + {
- + pattern = Pattern.compile(".*");
- + }
- + Matcher regexp = pattern.matcher(text);
- + return regexp.matches();
- + }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement