diff --git a/program/lib/Roundcube/rcube_utils.php b/program/lib/Roundcube/rcube_utils.php index e86f3c780..747371913 100644 --- a/program/lib/Roundcube/rcube_utils.php +++ b/program/lib/Roundcube/rcube_utils.php @@ -574,13 +574,15 @@ class rcube_utils // %n - host $n = self::server_name(); // %t - host name without first part, e.g. %n=mail.domain.tld, %t=domain.tld - $t = preg_replace('/^[^\.]+\./', '', $n); - // %d - domain name without first part - $d = preg_replace('/^[^\.]+\./', '', self::server_name('HTTP_HOST')); + // If %n=domain.tld then %t=domain.tld as well (remains valid) + $t = preg_replace('/^[^.]+\.(?![^.]+$)/', '', $n); + // %d - domain name without first part (up to domain.tld) + $d = preg_replace('/^[^.]+\.(?![^.]+$)/', '', self::server_name('HTTP_HOST')); // %h - IMAP host $h = $_SESSION['storage_host'] ?: $host; // %z - IMAP domain without first part, e.g. %h=imap.domain.tld, %z=domain.tld - $z = preg_replace('/^[^\.]+\./', '', $h); + // If %h=domain.tld then %z=domain.tld as well (remains valid) + $z = preg_replace('/^[^.]+\.(?![^.]+$)/', '', $h); // %s - domain name after the '@' from e-mail address provided at login screen. // Returns FALSE if an invalid email is provided if (strpos($name, '%s') !== false) {