From 3876e0537ef25cc04a30e47656c59eb2fc604c4b Mon Sep 17 00:00:00 2001 From: SengokuNadeko <70702835+SengokuNadeko@users.noreply.github.com> Date: Sat, 5 Sep 2020 14:34:46 -0400 Subject: [PATCH 1/2] Small regex fix Old regex had some problems (a bit too restrictive). If you want, you can push this to loosen up the restrictions a little. --- src/CNLoginServer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CNLoginServer.cpp b/src/CNLoginServer.cpp index da3233a..469beee 100644 --- a/src/CNLoginServer.cpp +++ b/src/CNLoginServer.cpp @@ -398,8 +398,8 @@ bool CNLoginServer::exitDuplicate(int accountId) } bool CNLoginServer::isLoginDataGood(std::string login, std::string password) { - std::regex loginRegex("^([A-Za-z\\d_\\-]){5,20}$"); - std::regex passwordRegex("^([A-Za-z\\d_\\-@$!%*#?&,.+:;<=>]){8,20}$"); + std::regex loginRegex("^(?=.*[A-Za-z0-9]$)[A-Za-z][A-Za-z\d.-]{3,20}$"); + std::regex passwordRegex("^(?=.*[A-Za-z0-9]$)[A-Za-z][A-Za-z\d.-]{3,20}$"); return (std::regex_match(login, loginRegex) && std::regex_match(password, passwordRegex)); } bool CNLoginServer::isPasswordCorrect(std::string actualPassword, std::string tryPassword) From 361c069d0cdacfd6ba96612cb9f68ca22944b75d Mon Sep 17 00:00:00 2001 From: SengokuNadeko <70702835+SengokuNadeko@users.noreply.github.com> Date: Sun, 6 Sep 2020 11:27:53 -0400 Subject: [PATCH 2/2] Adjustments to the regex I made the regex a bit less restrictive. If you want, you can push this if it seems appropriate. Username should be at least 4 characters and max 32 Password should be at least 8 characters and max 32 Usernames can be any combination of letters and numbers, with no special characters except for dash and underscore. Passwords can use any of the alphanumeric/special characters specified in the regex. --- src/CNLoginServer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CNLoginServer.cpp b/src/CNLoginServer.cpp index 469beee..98fc77a 100644 --- a/src/CNLoginServer.cpp +++ b/src/CNLoginServer.cpp @@ -398,8 +398,8 @@ bool CNLoginServer::exitDuplicate(int accountId) } bool CNLoginServer::isLoginDataGood(std::string login, std::string password) { - std::regex loginRegex("^(?=.*[A-Za-z0-9]$)[A-Za-z][A-Za-z\d.-]{3,20}$"); - std::regex passwordRegex("^(?=.*[A-Za-z0-9]$)[A-Za-z][A-Za-z\d.-]{3,20}$"); + std::regex loginRegex("[a-zA-Z0-9_-]{4,32}"); + std::regex passwordRegex("[a-zA-Z0-9!@#$%^&*()_+]{8,32}"); return (std::regex_match(login, loginRegex) && std::regex_match(password, passwordRegex)); } bool CNLoginServer::isPasswordCorrect(std::string actualPassword, std::string tryPassword)