fix: Validate that all application names are valid domain names

Invalid application names will need to be manually cleaned up by the user, and as such this is a bc-break.

Closes #3054
This commit is contained in:
Jose Diaz-Gonzalez
2018-02-13 03:30:27 -05:00
parent a80bd92f40
commit 16b8f2682b
3 changed files with 21 additions and 9 deletions

View File

@@ -141,11 +141,14 @@ is_valid_app_name() {
declare desc="verify app name format"
local APP="$1"
[[ ! -n "$APP" ]] && dokku_log_fail "APP must not be null"
if [[ ! "$APP" =~ ^[a-z].* && ! "$APP" =~ ^[0-9].* ]]; then
[[ -d "$DOKKU_ROOT/$APP" ]] && rm -rf "${DOKKU_ROOT:?}/$APP"
dokku_log_fail "App name must begin with lowercase alphanumeric character"
if [[ "$APP" =~ ^[a-z].* ]] || [[ "$APP" =~ ^[0-9].* ]]; then
if [[ ! $APP =~ [A-Z] ]] && [[ ! $APP =~ [:] ]]; then
return 0
fi
fi
return 0
[[ -d "$DOKKU_ROOT/$APP" ]] && rm -rf "${DOKKU_ROOT:?}/$APP"
dokku_log_fail "App name must begin with lowercase alphanumeric character"
}
verify_app_name() {