Skip to content

Commit 2c40a10

Browse files
authored
Update vhost-install.sh
1 parent e4acae6 commit 2c40a10

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

scripts/functions/vhost/vhost-install.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ while true; do
6767
echo "You entered: ${DOMAIN_NAME}"
6868
break
6969
else
70-
echo "Invalid domain name. Only lowercase letters, numbers, and hyphens are allowed."
70+
echo "Invalid domain name. Only lowercase letters, numbers, and hyphens are allowed. Hyphens cannot be at the start or end."
7171
fi
7272
done
7373

@@ -298,13 +298,15 @@ if [[ "${INSTALL_WORDPRESS}" == "1" ]]; then
298298
fi
299299

300300
# Username: 3-60 chars, must start with alphanumeric, letters/numbers/underscore/dot/hyphen
301+
# Length math: first class enforces 1 required leading char, `{2,59}` adds 2-59 more => 3-60 total.
301302
if [[ ! "${WP_ADMIN_USERNAME}" =~ ^[A-Za-z0-9][A-Za-z0-9_.-]{2,59}$ ]]; then
302303
echo "Error: WP_ADMIN_USERNAME is invalid. Use 3-60 characters: letters, numbers, underscore, dot, or hyphen." >&2
303304
exit 1
304305
fi
305306

306307
# Email: basic format validation
307-
if [[ ! "${WP_ADMIN_EMAIL}" =~ ^[A-Za-z0-9][A-Za-z0-9._%+-]*[A-Za-z0-9]@[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?)*\.[A-Za-z]{2,}$ ]]; then
308+
# Single character addresses such as [email protected] are valid and accepted by the regex.
309+
if [[ ! "${WP_ADMIN_EMAIL}" =~ ^[A-Za-z0-9]([A-Za-z0-9._%+-]*[A-Za-z0-9])?@[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?)*\.[A-Za-z]{2,}$ ]]; then
308310
echo "Error: WP_ADMIN_EMAIL is not a valid email address format." >&2
309311
exit 1
310312
fi

0 commit comments

Comments
 (0)