From dae41d279a43437aa7357182cc5095b59d1ea5e7 Mon Sep 17 00:00:00 2001 From: Jason Ertel Date: Wed, 22 Sep 2021 08:25:55 -0400 Subject: [PATCH] Prevent emails addresses from having uppercase characters --- salt/common/tools/sbin/so-user | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/salt/common/tools/sbin/so-user b/salt/common/tools/sbin/so-user index ac42a73b4..f7604d298 100755 --- a/salt/common/tools/sbin/so-user +++ b/salt/common/tools/sbin/so-user @@ -99,8 +99,7 @@ function validatePassword() { len=$(expr length "$password") if [[ $len -lt 6 ]]; then - echo "Password does not meet the minimum requirements" - exit 2 + fail "Password does not meet the minimum requirements" fi check_password_and_exit "$password" } @@ -109,8 +108,11 @@ function validateEmail() { email=$1 # (?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\]) if [[ ! "$email" =~ ^[[:alnum:]._%+-]+@[[:alnum:].-]+\.[[:alpha:]]{2,}$ ]]; then - echo "Email address is invalid" - exit 3 + fail "Email address is invalid" + fi + + if [[ "$email" =~ [A-Z] ]]; then + fail "Email addresses cannot contain uppercase letters" fi }