File tree Expand file tree Collapse file tree 3 files changed +16
-6
lines changed
Expand file tree Collapse file tree 3 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ is_object_valid 'user' 'USER' "$user"
4242is_object_valid ' mail' ' DOMAIN' " $domain "
4343is_object_valid " mail/$domain " ' ACCOUNT' " $account "
4444aliases=$( get_object_value " mail/$domain " ' ACCOUNT' " $account " ' $ALIAS' )
45- if [ -z " $( echo $aliases | grep -w $malias ) " ]; then
45+ if [ -z " $( echo $aliases | grep -w -e $malias ) " ]; then
4646 echo " Error: alias $malias doesn't exist"
4747 log_event " $E_NOTEXIST $ARGUMENTS "
4848 exit " $E_NOTEXIST "
Original file line number Diff line number Diff line change @@ -707,17 +707,19 @@ sync_cron_jobs() {
707707# Validates Local part email and mail alias
708708is_localpart_format_valid () {
709709 if [ ${# 1} -eq 1 ]; then
710- if ! [[ " $1 " =~ ^^ [[:alnum:]]$ ]]; then
710+ if ! [[ " $1 " =~ ^[[:alnum:]]$ ]]; then
711711 check_result " $E_INVALID " " invalid $2 format :: $1 "
712712 fi
713713 else
714714 if [ -n " $3 " ]; then
715715 maxlenght=$(( $3 - 2 ))
716- if ! [[ " $1 " =~ ^[[:alnum:]][-| \. | _[:alnum:]]{0,$maxlenght }[[:alnum:]]$ ]]; then
716+ # Allow leading and trailing special characters by adjusting the regex
717+ if ! [[ " $1 " =~ ^[[:alnum:]_.-][[:alnum:]_.-]{0,$maxlenght }[[:alnum:]_.-]$ ]]; then
717718 check_result " $E_INVALID " " invalid $2 format :: $1 "
718719 fi
719720 else
720- if ! [[ " $1 " =~ ^[[:alnum:]][-| \. | _[:alnum:]]{0,28}[[:alnum:]]$ ]]; then
721+ # Allow leading and trailing special characters by adjusting the regex
722+ if ! [[ " $1 " =~ ^[[:alnum:]_.-][[:alnum:]_.-]{0,28}[[:alnum:]_.-]$ ]]; then
721723 check_result " $E_INVALID " " invalid $2 format :: $1 "
722724 fi
723725 fi
Original file line number Diff line number Diff line change @@ -1701,13 +1701,21 @@ function check_ip_not_banned(){
17011701}
17021702
17031703@test " MAIL: Add account alias Invalid length" {
1704- run v-add-mail-account-alias $user $domain test ' hestiacp-realy -rocks-but-i-want-to-have-feature-xyz-and-i-want-it-now'
1704+ run v-add-mail-account-alias $user $domain test ' hestiacp-really -rocks-but-i-want-to-have-feature-xyz-and-i-want-it-now'
17051705 assert_failure $E_INVALID
17061706}
17071707@test " MAIL: Add account alias Invalid" {
1708- run v-add-mail-account-alias $user $domain test ' - test'
1708+ run v-add-mail-account-alias $user $domain test ' test+123 '
17091709 assert_failure $E_INVALID
17101710}
1711+ @test " MAIL: Add account alias starting with -" {
1712+ run v-add-mail-account-alias $user $domain test ' -test'
1713+ assert_success
1714+ }
1715+ @test " MAIL: Add account alias ending with -" {
1716+ run v-add-mail-account-alias $user $domain test ' test-'
1717+ assert_success
1718+ }
17111719@test " MAIL: Add account alias Invalid 2" {
17121720 run v-add-mail-account-alias $user $domain test ' hestia@test'
17131721 assert_failure $E_INVALID
You can’t perform that action at this time.
0 commit comments