@@ -724,9 +724,14 @@ is_common_format_valid() {
724724
725725# Database format validator
726726is_database_format_valid () {
727- exclude=" [!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|/|\|\" |'|;|%|\` | ]"
728- if [[ " $1 " =~ $exclude ]] || [ 65 -le ${# 1} ]; then
729- check_result $E_INVALID " invalid $2 format :: $1 "
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
730735 fi
731736}
732737
@@ -739,12 +744,17 @@ is_date_format_valid() {
739744
740745# Database user validator
741746is_dbuser_format_valid () {
742- exclude=" [!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|/|\|\" |'|;|%|\` | ]"
743- if [ 31 -le ${# 1} ]; then
744- check_result $E_INVALID " mysql username can be up to 30 characters long"
745- fi
746- if [[ " $1 " =~ $exclude ]]; then
747- check_result $E_INVALID " invalid $2 format :: $1 "
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
748758 fi
749759}
750760
@@ -931,10 +941,10 @@ is_format_valid() {
931941 charset) is_object_format_valid " $arg " " $arg_name " ;;
932942 charsets) is_common_format_valid " $arg " ' charsets' ;;
933943 comment) is_object_format_valid " $arg " ' comment' ;;
934- database) is_database_format_valid " $arg " ' database' ;;
944+ database) is_database_format_valid " $arg " ' database' $type ;;
935945 day) is_cron_format_valid " $arg " $arg_name ;;
936946 dbpass) is_password_format_valid " $arg " ;;
937- dbuser) is_dbuser_format_valid " $arg " ' dbuser' ;;
947+ dbuser) is_dbuser_format_valid " $arg " ' dbuser' $type ;;
938948 dkim) is_boolean_format_valid " $arg " ' dkim' ;;
939949 dkim_size) is_int_format_valid " $arg " ;;
940950 domain) is_domain_format_valid " $arg " ;;
0 commit comments