alecpl
2011-01-17 a76cbddfc92adbf4e8cb18dda5f668ec4de8a114
- Fix %h/%z variables in username_domain option (#1487701)


3 files modified
10 ■■■■■ changed files
CHANGELOG 1 ●●●● patch | view | raw | blame | history
program/include/main.inc 5 ●●●●● patch | view | raw | blame | history
program/include/rcmail.php 4 ●●●● patch | view | raw | blame | history
CHANGELOG
@@ -3,6 +3,7 @@
- Fix login redirect issues (#1487686)
- Require PHP 5.2.1 or greater
- Fix %h/%z variables in username_domain option (#1487701)
RELEASE 0.5
-----------
program/include/main.inc
@@ -1771,16 +1771,17 @@
 * Replaces hostname variables
 *
 * @param string $name Hostname
 * @param string $host Optional IMAP hostname
 * @return string
 */
function rcube_parse_host($name)
function rcube_parse_host($name, $host='')
{
  // %n - host
  $n = preg_replace('/:\d+$/', '', $_SERVER['SERVER_NAME']);
  // %d - domain name without first part, e.g. %d=mail.domain.tld, %m=domain.tld
  $d = preg_replace('/^[^\.]+\./', '', $n);
  // %h - IMAP host
  $h = $_SESSION['imap_host'];
  $h = $_SESSION['imap_host'] ? $_SESSION['imap_host'] : $host;
  // %z - IMAP domain without first part, e.g. %h=imap.domain.tld, %z=domain.tld
  $z = preg_replace('/^[^\.]+\./', '', $h);
program/include/rcmail.php
@@ -674,9 +674,9 @@
    // Check if we need to add domain
    if (!empty($config['username_domain']) && strpos($username, '@') === false) {
      if (is_array($config['username_domain']) && isset($config['username_domain'][$host]))
        $username .= '@'.rcube_parse_host($config['username_domain'][$host]);
        $username .= '@'.rcube_parse_host($config['username_domain'][$host], $host);
      else if (is_string($config['username_domain']))
        $username .= '@'.rcube_parse_host($config['username_domain']);
        $username .= '@'.rcube_parse_host($config['username_domain'], $host);
    }
    // Convert username to lowercase. If IMAP backend