浏览代码

[Web] Replace rtrim by preg_replace to fix transport checks

andryyy 5 年之前
父节点
当前提交
4ea843f087
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      data/web/inc/ajax/transport_check.php

+ 3 - 3
data/web/inc/ajax/transport_check.php

@@ -31,7 +31,7 @@ if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == "admi
     // Explode to hostname and port
     if ($has_bracket_and_port) {
       $port = substr($hostname_w_port, strrpos($hostname_w_port, ':') + 1);
-      $hostname = rtrim($hostname_w_port, ':' . $port);
+      $hostname = preg_replace('/'. preg_quote(':' . $port, '/') . '$/', '', $hostname_w_port);
       if (filter_var($hostname, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
         $hostname = '[' . $hostname . ']:';
       }
@@ -39,7 +39,7 @@ if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == "admi
     else {
       if ($is_ipv4_and_has_port) {
         $port = substr($hostname_w_port, strrpos($hostname_w_port, ':') + 1);
-        $hostname = rtrim($hostname_w_port, ':' . $port);
+        $hostname = preg_replace('/'. preg_quote(':' . $port, '/') . '$/', '', $hostname_w_port);
       }
       if (filter_var($hostname_w_port, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
         $hostname = $hostname_w_port;
@@ -51,7 +51,7 @@ if (isset($_SESSION['mailcow_cc_role']) && $_SESSION['mailcow_cc_role'] == "admi
       }
       else {
         $port = substr($hostname_w_port, strrpos($hostname_w_port, ':') + 1);
-        $hostname = rtrim($hostname_w_port, ':' . $port);
+        $hostname = preg_replace('/'. preg_quote(':' . $port, '/') . '$/', '', $hostname_w_port);
       }
     }
     // Try to get MX if host is not [host]