|
|
@@ -42,18 +42,22 @@ is_object_unsuspended 'user' 'USER' "$user"
|
|
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
|
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
|
|
|
|
|
-idn_redirect=$(idn2 --quiet $3)
|
|
|
-if [ $? == 0 ]; then
|
|
|
- redirect=$idn_redirect
|
|
|
-fi
|
|
|
-
|
|
|
if [[ "$3" =~ http://|https:// ]]; then
|
|
|
- scheme=1
|
|
|
+ scheme_check=1
|
|
|
+ scheme=$($HESTIA_PHP -r '$url=parse_url($argv[1]); echo $url["scheme"];' "$redirect")
|
|
|
+ host=$($HESTIA_PHP -r '$url=parse_url($argv[1]); echo $url["host"];' "$redirect")
|
|
|
+ path=$($HESTIA_PHP -r '$url=parse_url($argv[1]); if(!empty($url["path"])){echo $url["path"];}' "$redirect")
|
|
|
+ host=$(idn2 --quiet "$host")
|
|
|
+ redirect="$scheme://$host$path"
|
|
|
isValidUrl=$(php -r '$url=$argv[1]; $url=filter_var($url,FILTER_VALIDATE_URL); echo $url;' "$redirect")
|
|
|
if [ -z "$isValidUrl" ]; then
|
|
|
check_result $E_INVALID "Invalid redirect"
|
|
|
fi
|
|
|
else
|
|
|
+ host=$($HESTIA_PHP -r '$url=parse_url($argv[1]); echo $url["host"];' "http://$redirect")
|
|
|
+ path=$($HESTIA_PHP -r '$url=parse_url($argv[1]); if(!empty($url["path"])){echo $url["path"];}' "http://$redirect")
|
|
|
+ host=$(idn2 --quiet "$host")
|
|
|
+ redirect="$host$path"
|
|
|
isValidUrl=$(php -r '$url=$argv[1]; $url=filter_var($url,FILTER_VALIDATE_URL); echo $url;' "http://$redirect")
|
|
|
if [ -z "$isValidUrl" ]; then
|
|
|
check_result $E_INVALID "Invalid redirect"
|
|
|
@@ -72,9 +76,10 @@ if [ "$WEB_SYSTEM" = 'nginx' ] || [ "$PROXY_SYSTEM" = 'nginx' ]; then
|
|
|
conf="$HOMEDIR/$user/conf/web/$domain/nginx.conf_redirect"
|
|
|
sconf="$HOMEDIR/$user/conf/web/$domain/nginx.ssl.conf_redirect"
|
|
|
fi
|
|
|
+
|
|
|
# Insert redirect commands
|
|
|
if [ -n "$PROXY_SYSTEM" ] || [ "$WEB_SYSTEM" = 'nginx' ]; then
|
|
|
- if [ "$scheme" = 1 ]; then
|
|
|
+ if [ "$scheme_check" = 1 ]; then
|
|
|
echo " return $code $redirect\$request_uri;" > $conf
|
|
|
if [ ! -e "$sconf" ]; then
|
|
|
ln -s "$conf" "$sconf"
|