From fe2f0be4352ba0bc213a2c6d4dfcbbddea1a551c Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 21 Aug 2012 04:50:14 -0400
Subject: [PATCH] Fix possible PHP warning, read default_folders using config->get() to support deprecated option name (default_imap_folders)

---
 program/include/rcube_utils.php |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/program/include/rcube_utils.php b/program/include/rcube_utils.php
index 7f20dbb..d1a8315 100644
--- a/program/include/rcube_utils.php
+++ b/program/include/rcube_utils.php
@@ -47,7 +47,7 @@
         }
 
         $cookie = session_get_cookie_params();
-        $secure = self::https_check();
+        $secure = $cookie['secure'] || self::https_check();
 
         setcookie($name, $value, $exp, $cookie['path'], $cookie['domain'], $secure, true);
     }
@@ -84,9 +84,9 @@
 
         // from PEAR::Validate
         $regexp = '&^(?:
-	        ("\s*(?:[^"\f\n\r\t\v\b\s]+\s*)+")| 			 	            #1 quoted name
-	        ([-\w!\#\$%\&\'*+~/^`|{}=]+(?:\.[-\w!\#\$%\&\'*+~/^`|{}=]+)*)) 	#2 OR dot-atom (RFC5322)
-	        $&xi';
+            ("\s*(?:[^"\f\n\r\t\v\b\s]+\s*)+")|                             #1 quoted name
+            ([-\w!\#\$%\&\'*+~/^`|{}=]+(?:\.[-\w!\#\$%\&\'*+~/^`|{}=]+)*))  #2 OR dot-atom (RFC5322)
+            $&xi';
 
         if (!preg_match($regexp, $local_part)) {
             return false;
@@ -616,8 +616,10 @@
     {
         // %n - host
         $n = preg_replace('/:\d+$/', '', $_SERVER['SERVER_NAME']);
-        // %d - domain name without first part, e.g. %n=mail.domain.tld, %d=domain.tld
-        $d = preg_replace('/^[^\.]+\./', '', $n);
+        // %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('/^[^\.]+\./', '', $_SERVER['HTTP_HOST']);
         // %h - IMAP host
         $h = $_SESSION['storage_host'] ? $_SESSION['storage_host'] : $host;
         // %z - IMAP domain without first part, e.g. %h=imap.domain.tld, %z=domain.tld
@@ -632,7 +634,7 @@
             }
         }
 
-        $name = str_replace(array('%n', '%d', '%h', '%z', '%s'), array($n, $d, $h, $z, $s[2]), $name);
+        $name = str_replace(array('%n', '%t', '%d', '%h', '%z', '%s'), array($n, $t, $d, $h, $z, $s[2]), $name);
         return $name;
     }
 

--
Gitblit v1.9.1