Skip to content

Commit a793d94

Browse files
authored
Change DB name validation regex to lowercase only
Updated database name validation regex to be case-sensitive for lowercase.
1 parent 057112b commit a793d94

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

scripts/functions/vhost/vhost-install.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ if [[ "${INSTALL_WORDPRESS}" == "1" ]]; then
205205
database_password="${RAND_CHAR32}"
206206

207207
# Domain Database Credentials
208+
# No need to normalize database_user to lowercase as this is a Linux-only project that does not require windows compatibility.
208209
credentials_file="/home/EngineScript/mysql-credentials/${DOMAIN}.txt"
209210
# Create the file with restrictive permissions before writing any sensitive data
210211
install -m 600 /dev/null "${credentials_file}"
@@ -216,7 +217,7 @@ if [[ "${INSTALL_WORDPRESS}" == "1" ]]; then
216217
source "${credentials_file}"
217218

218219
# Validate DB identifier before interpolating into SQL
219-
if [[ -z "${DB}" || ! "${DB}" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then
220+
if [[ -z "${DB}" || ! "${DB}" =~ ^[a-z_][a-z0-9_]*$ ]]; then
220221
echo "Error: Invalid database name '${DB}' for domain '${DOMAIN}'." >&2
221222
exit 1
222223
fi

0 commit comments

Comments
 (0)