From 5293573116e0538e2af7b1935b768abdafbc1b61 Mon Sep 17 00:00:00 2001 From: darkredtitan <70135297+darkredtitan@users.noreply.github.com> Date: Sun, 8 Nov 2020 22:34:02 +0200 Subject: [PATCH] Allow period and numbers in firstname/lastname regex check (#144) * Remove unnecessary whitespace check in regex * Allow dot characters in names (except at the beginning of a name) * Allow numbers in names --- src/CNLoginServer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/CNLoginServer.cpp b/src/CNLoginServer.cpp index d3a8362..710a749 100644 --- a/src/CNLoginServer.cpp +++ b/src/CNLoginServer.cpp @@ -438,8 +438,9 @@ bool CNLoginServer::isPasswordCorrect(std::string actualPassword, std::string tr } bool CNLoginServer::isCharacterNameGood(std::string Firstname, std::string Lastname) { - std::regex firstnamecheck("[a-zA-Z0-9]+(?: [a-zA-Z0-9]+)*$"); - std::regex lastnamecheck("[a-zA-Z0-9]+(?: [a-zA-Z0-9]+)*$"); + //Allow alphanumeric and dot characters in names(disallows dot and space characters at the beginning of a name) + std::regex firstnamecheck(R"(((?! )(?!\.)[a-zA-Z0-9]*\.{0,1}(?!\.+ +)[a-zA-Z0-9]* {0,1}(?! +))*$)"); + std::regex lastnamecheck(R"(((?! )(?!\.)[a-zA-Z0-9]*\.{0,1}(?!\.+ +)[a-zA-Z0-9]* {0,1}(?! +))*$)"); return (std::regex_match(Firstname, firstnamecheck) && std::regex_match(Lastname, lastnamecheck)); } #pragma endregion helperMethods