From 8fc518dba80466a30f18c75efa890b2083998003 Mon Sep 17 00:00:00 2001 From: Shobu UMEMURA <1465446+ogumemura@users.noreply.github.com> Date: Sat, 28 Sep 2024 17:57:02 +0900 Subject: [PATCH] Fix username validation regex to correctly recognize hyphen (-) This pull request corrects the regular expression used for username validation to correctly recognize hyphens (-). Changes Made: Changed the regex pattern from ^([a-zA-Z0-9_.-@])+$ to ^([a-zA-Z0-9_.\-@])+$. Reason for Change: In the previous regex, the hyphen (-) within the character class was interpreted as a range operator, not as a literal character. This caused usernames with hyphens to be incorrectly marked as invalid. By escaping the hyphen (\-), the regex now correctly recognizes it as a literal character. This ensures that usernames containing hyphens are validated properly. Points of Verification: Confirmed that usernames containing hyphens are now correctly recognized and pass the validation. Verified that other characters (letters, numbers, underscores, dots, and at signs) are still being properly validated. --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index faf75ec..145a942 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,7 @@ import ( ) const ( - usernameRegexp = `^([a-zA-Z0-9_.-@])+$` + usernameRegexp = `^([a-zA-Z0-9_.\-@])+$` passwordMinLength = 6 certsArchiveFileName = "certs.tar.gz" ccdArchiveFileName = "ccd.tar.gz"