@@ -724,14 +724,9 @@ is_common_format_valid() {
724724
725725# Database format validator
726726is_database_format_valid () {
727- if [ " $3 " == " pgsql" ]; then
728- if ! [[ " $1 " =~ ^[0-9a-z_]{1,63}$ ]]; then
729- check_result $E_INVALID " invalid $2 format :: $1 "
730- fi
731- else
732- if ! [[ " $1 " =~ ^[0-9a-zA-Z_]{1,64}$ ]]; then
733- check_result $E_INVALID " invalid $2 format :: $1 "
734- fi
727+ exclude=" [!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|/|\|\" |'|;|%|\` | ]"
728+ if [[ " $1 " =~ $exclude ]] || [ 64 -le ${# 1} ]; then
729+ check_result $E_INVALID " invalid $2 format :: $1 "
735730 fi
736731}
737732
@@ -744,17 +739,12 @@ is_date_format_valid() {
744739
745740# Database user validator
746741is_dbuser_format_valid () {
747- if [ " $3 " == " pgsql" ]; then
748- if ! [[ " $1 " =~ ^[0-9a-z_]{1,63}$ ]]; then
749- check_result $E_INVALID " invalid $2 format :: $1 "
750- fi
751- else
752- if [ 33 -le ${# 1} ]; then
753- check_result $E_INVALID " mysql username can be up to 32 characters long"
754- fi
755- if ! [[ " $1 " =~ ^[0-9a-zA-Z_]{1,64}$ ]]; then
756- check_result $E_INVALID " invalid $2 format :: $1 "
757- fi
742+ exclude=" [!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|/|\|\" |'|;|%|\` | ]"
743+ if [ 33 -le ${# 1} ]; then
744+ check_result $E_INVALID " mysql username can be up to 32 characters long"
745+ fi
746+ if [[ " $1 " =~ $exclude ]]; then
747+ check_result $E_INVALID " invalid $2 format :: $1 "
758748 fi
759749}
760750
@@ -948,10 +938,10 @@ is_format_valid() {
948938 charset) is_object_format_valid " $arg " " $arg_name " ;;
949939 charsets) is_common_format_valid " $arg " ' charsets' ;;
950940 comment) is_object_format_valid " $arg " ' comment' ;;
951- database) is_database_format_valid " $arg " ' database' $type ;;
941+ database) is_database_format_valid " $arg " ' database' ;;
952942 day) is_cron_format_valid " $arg " $arg_name ;;
953943 dbpass) is_password_format_valid " $arg " ;;
954- dbuser) is_dbuser_format_valid " $arg " ' dbuser' $type ;;
944+ dbuser) is_dbuser_format_valid " $arg " ' dbuser' ;;
955945 dkim) is_boolean_format_valid " $arg " ' dkim' ;;
956946 dkim_size) is_int_format_valid " $arg " ;;
957947 domain) is_domain_format_valid " $arg " ;;
0 commit comments