Skip to content

Commit f506316

Browse files
authored
hestiacp#2272 Fix issue where email validator didn't allow idn domains (hestiacp#2273)
* Fix issue where email validator didn't allow idn domains * Fix duplicated test name
1 parent 73e5d5d commit f506316

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

func/main.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,9 @@ is_dns_record_format_valid() {
925925
# Email format validator
926926
is_email_format_valid() {
927927
if [[ ! "$1" =~ ^[A-Za-z0-9._%+-]+@[[:alnum:].-]+\.[A-Za-z]{2,63}$ ]] ; then
928+
if [[ ! "$1" =~ ^[A-Za-z0-9._%+-]+@[[:alnum:].-]+\.(xn--)[[:alnum:]]{2,63}$ ]] ; then
928929
check_result "$E_INVALID" "invalid email format :: $1"
930+
fi
929931
fi
930932
}
931933

test/test.bats

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -748,26 +748,37 @@ function check_ip_not_banned(){
748748
}
749749

750750
@test "WEB: Add IDN domain ASCII idn-tést.eu" {
751-
# Expected to fail due to utf exists
752-
run v-add-web-domain $user $( idn -a idn-tést.eu) 198.18.0.125
753-
assert_failure $E_EXISTS
751+
# Expected to fail due to utf exists
752+
run v-add-web-domain $user $( idn -a idn-tést.eu) 198.18.0.125
753+
assert_failure $E_EXISTS
754+
}
755+
754756

757+
@test "WEB: Generate Self signed certificate ASCII idn-tést.eu" {
758+
run v-generate-ssl-cert "xn--idn-tst-fya.eu" "info@xn--idn-tst-fya.eu" US CA "Orange County" HestiaCP IT "mail.xn--idn-tst-fya.eu"
759+
assert_success
755760
}
756761

762+
757763
@test "WEB: Delete IDN domain idn-tést.eu" {
758-
run v-delete-web-domain $user idn-tést.eu
759-
assert_success
760-
refute_output
764+
run v-delete-web-domain $user idn-tést.eu
765+
assert_success
766+
refute_output
761767
}
762768

763-
@test "WEB: Add IDN domain UTF bløst.com" {
764-
run v-add-web-domain $user bløst.com 198.18.0.125
765-
assert_success
766-
refute_output
769+
@test "WEB: Add IDN domain UTF bløst.рф" {
770+
run v-add-web-domain $user bløst.рф 198.18.0.125
771+
assert_success
772+
refute_output
773+
}
774+
775+
@test "WEB: Generate Self signed certificate ASCII bløst.рф" {
776+
run v-generate-ssl-cert "xn--blst-hra.xn--p1ai" "info@xn--blst-hra.xn--p1ai" US CA "Orange County" HestiaCP IT "mail.xn--blst-hra.xn--p1ai"
777+
assert_success
767778
}
768779

769-
@test "WEB: Delete IDN domain bløst.com" {
770-
run v-delete-web-domain $user bløst.com
780+
@test "WEB: Delete IDN domain bløst.рф" {
781+
run v-delete-web-domain $user bløst.рф
771782
assert_success
772783
refute_output
773784
}

0 commit comments

Comments
 (0)