validate username in online mode

Usernames are used in file names and URLs, so a '/' could write files
outside the game directory and a space broke the share links. Only
allow a-z, 0-9 and _ (max 32 chars) and re-prompt otherwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
abrown38andClaude Opus 5.5 committed 2026-09-29 17:12:44 +00:00
1 parent 437d46e975
commit 1f6a5b4a44
1 file changed
+7 -1
+7 -1
View File
@@ -140,9 +140,15 @@ function set_options() {
echo -en "${CLEAR_SCREEN}"
declare -g USER
read -r -p "Username: " USER
read -r -p "Username: " USER || exit 1
USER="${USER,,}"
# Username is used in file names and URLs so only allow safe characters
while [[ -z "${USER}" || "${USER}" == *[!a-z0-9_]* || ${#USER} -gt 32 ]]; do
read -r -p "${CLEAR_UP1}Username (letters, numbers and _ only): " USER || exit 1
USER="${USER,,}"
done
declare -g DAY
DAY=$(( EPOCHSECONDS / 86400 ))