Skip to content

Commit f5c3000

Browse files
authored
Merge pull request hestiacp#2033 from hestiacp/fix/2029-idn-problems
Fix multiple bugs with IDN domains and Aliases
2 parents 6bc9630 + 2c1a0e9 commit f5c3000

File tree

4 files changed

+87
-31
lines changed

4 files changed

+87
-31
lines changed

func/domain.sh

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -49,36 +49,43 @@ is_web_domain_new() {
4949

5050
# Web alias existence check
5151
is_web_alias_new() {
52-
web_alias=$(grep -wH "$1" $HESTIA/data/users/*/web.conf)
53-
if [ ! -z "$web_alias" ]; then
54-
a1=$(echo "$web_alias" |grep -F "'$1'" |cut -f 7 -d /)
55-
if [ ! -z "$a1" ] && [ "$2" == "web" ]; then
56-
check_result $E_EXISTS "Web alias $1 exists"
57-
fi
58-
if [ ! -z "$a1" ] && [ "$a1" != "$user" ]; then
59-
check_result $E_EXISTS "Web alias $1 exists"
60-
fi
61-
a2=$(echo "$web_alias" |grep -F "'$1," |cut -f 7 -d /)
62-
if [ ! -z "$a2" ] && [ "$2" == "web" ]; then
63-
check_result $E_EXISTS "Web alias $1 exists"
64-
fi
65-
if [ ! -z "$a2" ] && [ "$a2" != "$user" ]; then
66-
check_result $E_EXISTS "Web alias $1 exists"
67-
fi
68-
a3=$(echo "$web_alias" |grep -F ",$1," |cut -f 7 -d /)
69-
if [ ! -z "$a3" ] && [ "$2" == "web" ]; then
70-
check_result $E_EXISTS "Web alias $1 exists"
71-
fi
72-
if [ ! -z "$a3" ] && [ "$a3" != "$user" ]; then
73-
check_result $E_EXISTS "Web alias $1 exists"
74-
fi
75-
a4=$(echo "$web_alias" |grep -F ",$1'" |cut -f 7 -d /)
76-
if [ ! -z "$a4" ] && [ "$2" == "web" ]; then
77-
check_result $E_EXISTS "Web alias $1 exists"
78-
fi
79-
if [ ! -z "$a4" ] && [ "$a4" != "$user" ]; then
80-
check_result $E_EXISTS "Web alias $1 exists"
52+
grep -wH "$1" $HESTIA/data/users/*/web.conf | while read -r line ; do
53+
user=$(echo $line |cut -f 7 -d /)
54+
string=$(echo $line |cut -f 2- -d ':')
55+
parse_object_kv_list $string
56+
if [ ! -z "$ALIAS" ]; then
57+
a1=$(echo "'$ALIAS'" |grep -F "'$1'");
58+
if [ ! -z "$a1" ] && [ "$2" == "web" ]; then
59+
return $E_EXISTS
60+
fi
61+
if [ ! -z "$a1" ] && [ "$user" != "$user" ]; then
62+
return $E_EXISTS
63+
fi
64+
a2=$(echo "'$ALIAS'" |grep -F "'$1,")
65+
if [ ! -z "$a2" ] && [ "$2" == "web" ]; then
66+
return $E_EXISTS
67+
fi
68+
if [ ! -z "$a2" ] && [ "$user" != "$user" ]; then
69+
return $E_EXISTS
70+
fi
71+
a3=$(echo "'$ALIAS'" |grep -F ",$1," )
72+
if [ ! -z "$a3" ] && [ "$2" == "web" ]; then
73+
return $E_EXISTS
74+
fi
75+
if [ ! -z "$a3" ] && [ "$user" != "$user" ]; then
76+
return $E_EXISTS
77+
fi
78+
a4=$(echo "'$ALIAS'" |grep -F ",$1'")
79+
if [ ! -z "$a4" ] && [ "$2" == "web" ]; then
80+
return $E_EXISTS
81+
fi
82+
if [ ! -z "$a4" ] && [ "$user" != "$user" ]; then
83+
return $E_EXISTS
84+
fi
8185
fi
86+
done
87+
if [ $? -ne 0 ]; then
88+
check_result $E_EXISTS "Web alias $1 exists"
8289
fi
8390
}
8491

install/hst-install-debian.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ fi
285285
if [ "$iptables" = 'no' ]; then
286286
fail2ban='no'
287287
fi
288+
if [ "$apache" = "no" ]; then
289+
phpfpm='yes'
290+
fi
288291

289292
# Checking root permissions
290293
if [ "x$(id -u)" != 'x0' ]; then
@@ -1232,6 +1235,7 @@ $HESTIA/bin/v-change-user-role admin admin
12321235
$HESTIA/bin/v-change-user-language admin $lang
12331236
$HESTIA/bin/v-change-sys-config-value 'POLICY_SYSTEM_PROTECTED_ADMIN' 'yes'
12341237

1238+
locale-gen "en_US.utf8" > /dev/null 2>&1
12351239
#----------------------------------------------------------#
12361240
# Configure Nginx #
12371241
#----------------------------------------------------------#

install/hst-install-ubuntu.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ fi
266266
if [ "$iptables" = 'no' ]; then
267267
fail2ban='no'
268268
fi
269+
if [ "$apache" = "no" ]; then
270+
phpfpm='yes'
271+
fi
269272

270273
# Checking root permissions
271274
if [ "x$(id -u)" != 'x0' ]; then
@@ -1271,6 +1274,7 @@ $HESTIA/bin/v-change-user-role admin admin
12711274
$HESTIA/bin/v-change-user-language admin $lang
12721275
$HESTIA/bin/v-change-sys-config-value 'POLICY_SYSTEM_PROTECTED_ADMIN' 'yes'
12731276

1277+
locale-gen "en_US.utf8" > /dev/null 2>&1
12741278

12751279
#----------------------------------------------------------#
12761280
# Configure Nginx #

test/test.bats

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ function validate_web_domain() {
6969
fi
7070

7171
# Test HTTP
72-
run curl --location --silent --show-error --insecure --resolve "${domain}:80:${domain_ip}" "http://${domain}/${webpath}"
72+
# Curl hates UTF domains so convert them to ascci.
73+
domain_idn=$(idn -a $domain)
74+
run curl --location --silent --show-error --insecure --resolve "${domain_idn}:80:${domain_ip}" "http://${domain_idn}/${webpath}"
7375
assert_success
7476
assert_output --partial "$webproof"
7577

@@ -78,7 +80,7 @@ function validate_web_domain() {
7880
run v-list-web-domain-ssl $user $domain
7981
assert_success
8082

81-
run curl --location --silent --show-error --insecure --resolve "${domain}:443:${domain_ip}" "https://${domain}/${webpath}"
83+
run curl --location --silent --show-error --insecure --resolve "${domain_idn}:443:${domain_ip}" "https://${domain_idn}/${webpath}"
8284
assert_success
8385
assert_output --partial "$webproof"
8486
fi
@@ -648,7 +650,46 @@ function validate_database(){
648650
assert_success
649651
refute_output
650652
}
653+
654+
#----------------------------------------------------------#
655+
# IDN #
656+
#----------------------------------------------------------#
657+
658+
@test "WEB: Add IDN domain UTF idn-tést.eu" {
659+
run v-add-web-domain $user idn-tést.eu 198.18.0.125
660+
assert_success
661+
refute_output
662+
663+
echo -e "<?php\necho 'Hestia Test:'.(4*3);" > $HOMEDIR/$user/web/idn-tést.eu/public_html/php-test.php
664+
validate_web_domain $user idn-tést.eu 'Hestia Test:12' 'php-test.php'
665+
rm $HOMEDIR/$user/web/idn-tést.eu/public_html/php-test.php
666+
}
667+
668+
@test "WEB: Add IDN domain ASCII idn-tést.eu" {
669+
# Expected to fail due to utf exists
670+
run v-add-web-domain $user $( idn -a idn-tést.eu) 198.18.0.125
671+
assert_failure $E_EXISTS
672+
673+
}
674+
675+
@test "WEB: Delete IDN domain idn-tést.eu" {
676+
run v-delete-web-domain $user idn-tést.eu
677+
assert_success
678+
refute_output
679+
}
651680

681+
@test "WEB: Add IDN domain UTF bløst.com" {
682+
run v-add-web-domain $user bløst.com 198.18.0.125
683+
assert_success
684+
refute_output
685+
}
686+
687+
@test "WEB: Delete IDN domain bløst.com" {
688+
run v-delete-web-domain $user bløst.com
689+
assert_success
690+
refute_output
691+
}
692+
652693
#----------------------------------------------------------#
653694
# MULTIPHP #
654695
#----------------------------------------------------------#

0 commit comments

Comments
 (0)