Skip to content

Commit 04d7500

Browse files
Update lib/sanitize.sh
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent b70fc39 commit 04d7500

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

lib/sanitize.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,11 @@ sanitize_database_name() {
171171

172172
# Database names should only contain alphanumeric and underscores
173173
local sanitized
174-
sanitized=$(echo "$name" | sed 's/[^a-zA-Z0-9_]//g')
174+
sanitized=$(echo "$name" | sed 's/[^a-zA-Z0-9_]//g' | sed 's/^[0-9]/_&/')
175175

176-
# Must start with letter or underscore
177-
if [[ ! "$sanitized" =~ ^[a-zA-Z_][a-zA-Z0-9_]*$ ]]; then
178-
log_error "Invalid database name: $name"
179-
log_error "Database name must start with letter or underscore and contain only alphanumeric characters and underscores"
180-
exit 1
176+
# Log a warning if the name was modified
177+
if [[ "$sanitized" != "$name" ]]; then
178+
log_warning "Database name modified to conform to requirements: $sanitized"
181179
fi
182180

183181
echo "$sanitized"

0 commit comments

Comments
 (0)