Changeset 3fec695 in github


Ignore:
Timestamp:
Nov 15, 2011 5:50:30 AM (19 months ago)
Author:
alecpl <alec@…>
Branches:
release-0.7
Children:
3fd5e2e
Parents:
ecfaed5
Message:
  • Applied fixes from trunk up to r5425
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    recfaed5 r3fec695  
    22=========================== 
    33 
     4- Fix listing of folders in hidden namespaces (#1486796) 
     5- Don't consider \Noselect flag when building folders tree (#1488004) 
     6- Fix sorting autocomplete results (#1488084) 
     7- Add option to set session name (#1486433) 
    48- Add option to skip alternative email addresses in autocompletion 
    59- Fix inconsistent behaviour of Compose button in Drafts folder, add Edit button for drafts 
  • config/main.inc.php.dist

    recfaed5 r3fec695  
    223223$rcmail_config['session_domain'] = ''; 
    224224 
     225// session name. Default: 'roundcube_sessid' 
     226$rcmail_config['session_name'] = null; 
     227 
    225228// Backend to use for session storage. Can either be 'db' (default) or 'memcache' 
    226229// If set to memcache, a list of servers need to be specified in 'memcache_hosts' 
     
    419422$rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'Junk', 'Trash'); 
    420423 
    421 // automatically create the above listed default folders on login 
     424// automatically create the above listed default folders on first login 
    422425$rcmail_config['create_default_folders'] = false; 
    423426 
  • plugins/password/config.inc.php.dist

    r5da48a9 r3fec695  
    4848$rcmail_config['password_query'] = 'SELECT update_passwd(%c, %u)'; 
    4949 
     50// By default domains in variables are using unicode. 
     51// Enable this option to use punycoded names 
     52$rcmail_config['password_idn_ascii'] = false; 
     53 
    5054// Path for dovecotpw (if not in $PATH) 
    5155// $rcmail_config['password_dovecotpw'] = '/usr/local/sbin/dovecotpw'; 
  • plugins/password/drivers/sql.php

    r5da48a9 r3fec695  
    3838    if (strpos($sql, '%c') !== FALSE) { 
    3939        $salt = ''; 
    40         if (CRYPT_MD5) {  
    41             $len = rand(3, CRYPT_SALT_LENGTH); 
     40        if (CRYPT_MD5) { 
     41            // Always use eight salt characters for MD5 (#1488136) 
     42            $len = 8; 
    4243        } else if (CRYPT_STD_DES) { 
    4344            $len = 2; 
     
    4546            return PASSWORD_CRYPT_ERROR; 
    4647        } 
     48 
     49        //Restrict the character set used as salt (#1488136) 
     50        $seedchars = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; 
    4751        for ($i = 0; $i < $len ; $i++) { 
    48             $salt .= chr(rand(ord('.'), ord('z'))); 
     52            $salt .= $seedchars[rand(0, 63)]; 
    4953        } 
     54 
    5055        $sql = str_replace('%c',  $db->quote(crypt($passwd, CRYPT_MD5 ? '$1$'.$salt.'$' : $salt)), $sql); 
    5156    } 
     
    126131    } 
    127132 
     133    $local_part  = $rcmail->user->get_username('local'); 
     134    $domain_part = $rcmail->user->get_username('domain'); 
     135    $username    = $_SESSION['username']; 
     136    $host        = $_SESSION['imap_host']; 
     137 
     138    // convert domains to/from punnycode 
     139    if ($rcmail->config->get('password_idn_ascii')) { 
     140        $domain_part = rcube_idn_to_ascii($domain_part); 
     141        $username    = rcube_idn_to_ascii($username); 
     142        $host        = rcube_idn_to_ascii($host); 
     143    } 
     144    else { 
     145        $domain_part = rcube_idn_to_utf8($domain_part); 
     146        $username    = rcube_idn_to_utf8($username); 
     147        $host        = rcube_idn_to_utf8($host); 
     148    } 
     149 
    128150    // at least we should always have the local part 
    129     $sql = str_replace('%l', $db->quote($rcmail->user->get_username('local'), 'text'), $sql); 
    130     $sql = str_replace('%d', $db->quote($rcmail->user->get_username('domain'), 'text'), $sql); 
    131     $sql = str_replace('%u', $db->quote($_SESSION['username'],'text'), $sql); 
    132     $sql = str_replace('%h', $db->quote($_SESSION['imap_host'],'text'), $sql); 
     151    $sql = str_replace('%l', $db->quote($local_part, 'text'), $sql); 
     152    $sql = str_replace('%d', $db->quote($domain_part, 'text'), $sql); 
     153    $sql = str_replace('%u', $db->quote($username, 'text'), $sql); 
     154    $sql = str_replace('%h', $db->quote($host, 'text'), $sql); 
    133155 
    134156    $res = $db->query($sql, $sql_vars); 
  • plugins/password/package.xml

    r5da48a9 r3fec695  
    2828        <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU GPLv2</license> 
    2929        <notes> 
    30 - When old and new passwords are the same, do nothing, return success (#1487823) 
    31 - Fixed Samba password hashing in 'ldap' driver 
    32 - Added 'password_change' hook for plugin actions after successful password change 
    33 - Fixed bug where 'doveadm pw' command was used as dovecotpw utility 
     30- Added option to use punycode or unicode for domain names (#1488103) 
    3431    </notes> 
    3532        <contents> 
     
    265262            </notes> 
    266263        </release> 
     264        <release> 
     265                <date>2011-10-26</date> 
     266                <time>12:00</time> 
     267                <version> 
     268                        <release>2.3</release> 
     269                        <api>1.6</api> 
     270                </version> 
     271                <stability> 
     272                        <release>stable</release> 
     273                        <api>stable</api> 
     274                </stability> 
     275                <license uri="http://www.gnu.org/licenses/gpl-2.0.html">GNU GPLv2</license> 
     276                <notes> 
     277- When old and new passwords are the same, do nothing, return success (#1487823) 
     278- Fixed Samba password hashing in 'ldap' driver 
     279- Added 'password_change' hook for plugin actions after successful password change 
     280- Fixed bug where 'doveadm pw' command was used as dovecotpw utility 
     281- Improve generated crypt() passwords (#1488136) 
     282            </notes> 
     283        </release> 
    267284    </changelog> 
    268285</package> 
  • plugins/password/password.php

    r5da48a9 r3fec695  
    224224        $config = rcmail::get_instance()->config; 
    225225        $driver = $this->home.'/drivers/'.$config->get('password_driver', 'sql').'.php'; 
    226      
     226 
    227227        if (!is_readable($driver)) { 
    228228            raise_error(array( 
     
    234234            return $this->gettext('internalerror'); 
    235235        } 
    236      
     236 
    237237        include($driver); 
    238238 
     
    271271 
    272272        return $reason; 
    273     }                                      
     273    } 
    274274} 
  • program/include/main.inc

    r51f7a5b r3fec695  
    12821282 
    12831283  if (!isset($arrFolders[$currentFolder])) { 
    1284     // Check \Noselect attribute (if attributes are in cache) 
    1285     if (!$virtual && ($attrs = $RCMAIL->imap->mailbox_attributes($path))) { 
    1286       $virtual = in_array('\\Noselect', $attrs); 
    1287     } 
    1288  
    12891284    $arrFolders[$currentFolder] = array( 
    12901285      'id' => $path, 
     
    13141309  $msgcounts = $RCMAIL->imap->get_cache('messagecount'); 
    13151310 
    1316   $idx = 0; 
    13171311  $out = ''; 
    13181312  foreach ($arrFolders as $key => $folder) { 
    1319     $title = null; 
    1320  
    1321     if (($folder_class = rcmail_folder_classname($folder['id'])) && !$realnames) { 
     1313    $title        = null; 
     1314    $folder_class = rcmail_folder_classname($folder['id']); 
     1315    $collapsed    = strpos($CONFIG['collapsed_folders'], '&'.rawurlencode($folder['id']).'&') !== false; 
     1316    $unread       = $msgcounts ? intval($msgcounts[$folder['id']]['UNSEEN']) : 0; 
     1317 
     1318    if ($folder_class && !$realnames) { 
    13221319      $foldername = rcube_label($folder_class); 
    13231320    } 
     
    13391336 
    13401337    // set special class for Sent, Drafts, Trash and Junk 
    1341     if ($folder['id'] == $CONFIG['sent_mbox']) 
    1342       $classes[] = 'sent'; 
    1343     else if ($folder['id'] == $CONFIG['drafts_mbox']) 
    1344       $classes[] = 'drafts'; 
    1345     else if ($folder['id'] == $CONFIG['trash_mbox']) 
    1346       $classes[] = 'trash'; 
    1347     else if ($folder['id'] == $CONFIG['junk_mbox']) 
    1348       $classes[] = 'junk'; 
    1349     else if ($folder['id'] == 'INBOX') 
    1350       $classes[] = 'inbox'; 
    1351     else 
    1352       $classes[] = '_'.asciiwords($folder_class ? $folder_class : strtolower($folder['id']), true); 
     1338    if ($folder_class) 
     1339      $classes[] = $folder_class; 
    13531340 
    13541341    if ($folder['id'] == $mbox_name) 
    13551342      $classes[] = 'selected'; 
    1356  
    1357     $collapsed = strpos($CONFIG['collapsed_folders'], '&'.rawurlencode($folder['id']).'&') !== false; 
    1358     $unread = $msgcounts ? intval($msgcounts[$folder['id']]['UNSEEN']) : 0; 
    13591343 
    13601344    if ($folder['virtual']) 
     
    13911375 
    13921376    $out .= "</li>\n"; 
    1393     $idx++; 
    13941377  } 
    13951378 
  • program/include/rcmail.php

    r51f7a5b r3fec695  
    679679      return; 
    680680 
     681    $sess_name   = $this->config->get('session_name'); 
     682    $sess_domain = $this->config->get('session_domain'); 
     683    $lifetime    = $this->config->get('session_lifetime', 0) * 60; 
     684 
    681685    // set session domain 
    682     if ($domain = $this->config->get('session_domain')) { 
    683       ini_set('session.cookie_domain', $domain); 
     686    if ($sess_domain) { 
     687      ini_set('session.cookie_domain', $sess_domain); 
    684688    } 
    685689    // set session garbage collecting time according to session_lifetime 
    686     $lifetime = $this->config->get('session_lifetime', 0) * 60; 
    687690    if ($lifetime) { 
    688691      ini_set('session.gc_maxlifetime', $lifetime * 2); 
     
    690693 
    691694    ini_set('session.cookie_secure', rcube_https_check()); 
    692     ini_set('session.name', 'roundcube_sessid'); 
     695    ini_set('session.name', $sess_name ? $sess_name : 'roundcube_sessid'); 
    693696    ini_set('session.use_cookies', 1); 
    694697    ini_set('session.use_only_cookies', 1); 
  • program/include/rcube_imap.php

    recfaed5 r3fec695  
    13741374 
    13751375        $result = 0; 
     1376 
     1377        if (empty($old)) { 
     1378            return $result; 
     1379        } 
     1380 
    13761381        $new = $this->get_folder_stats($mailbox); 
    13771382 
     
    30003005 
    30013006    /** 
    3002      * Private method for mailbox listing 
     3007     * Private method for mailbox listing (LSUB) 
    30033008     * 
    30043009     * @param   string  $root   Optional root folder 
     
    30073012     * @param   string  $rights Optional ACL requirements 
    30083013     * 
    3009      * @return  array   List of mailboxes/folders 
     3014     * @return  array   List of subscribed folders 
    30103015     * @see     rcube_imap::list_mailboxes() 
    30113016     * @access  private 
     
    31103115        else { 
    31113116            // retrieve list of folders from IMAP server 
    3112             $a_mboxes = $this->conn->listMailboxes($root, $name); 
     3117            $a_mboxes = $this->_list_unsubscribed($root, $name); 
    31133118        } 
    31143119 
     
    31413146 
    31423147        return $a_mboxes; 
     3148    } 
     3149 
     3150 
     3151    /** 
     3152     * Private method for mailbox listing (LIST) 
     3153     * 
     3154     * @param   string  $root   Optional root folder 
     3155     * @param   string  $name   Optional name pattern 
     3156     * 
     3157     * @return  array   List of folders 
     3158     * @see     rcube_imap::list_unsubscribed() 
     3159     */ 
     3160    private function _list_unsubscribed($root='', $name='*') 
     3161    { 
     3162        $result = $this->conn->listMailboxes($root, $name); 
     3163 
     3164        if (!is_array($result)) { 
     3165            return array(); 
     3166        } 
     3167 
     3168        // #1486796: some server configurations doesn't 
     3169        // return folders in all namespaces, we'll try to detect that situation 
     3170        // and ask for these namespaces separately 
     3171        if ($root == '' && $name = '*') { 
     3172            $delim     = $this->get_hierarchy_delimiter(); 
     3173            $namespace = $this->get_namespace(); 
     3174            $search    = array(); 
     3175 
     3176            // build list of namespace prefixes 
     3177            foreach ((array)$namespace as $ns) { 
     3178                if (is_array($ns)) { 
     3179                    foreach ($ns as $ns_data) { 
     3180                        if (strlen($ns_data[0])) { 
     3181                            $search = $ns_data[0]; 
     3182                        } 
     3183                    } 
     3184                } 
     3185            } 
     3186 
     3187            if (!empty($search)) { 
     3188                // go through all folders detecting namespace usage 
     3189                foreach ($result as $folder) { 
     3190                    foreach ($search as $idx => $prefix) { 
     3191                        if (strpos($folder, $prefix) === 0) { 
     3192                            unset($search[$idx]); 
     3193                        } 
     3194                    } 
     3195                    if (empty($search)) { 
     3196                        break; 
     3197                    } 
     3198                } 
     3199 
     3200                // get folders in hidden namespaces and add to the result 
     3201                foreach ($search as $prefix) { 
     3202                    $list = $this->conn->listMailboxes($prefix, $name); 
     3203 
     3204                    if (!empty($list)) { 
     3205                        $result = array_merge($result, $list); 
     3206                    } 
     3207                } 
     3208            } 
     3209        } 
     3210 
     3211        return $result; 
    31433212    } 
    31443213 
     
    34163485            if (is_array($namespace)) { 
    34173486                foreach ($namespace as $ns) { 
    3418                     if (strlen($ns[0])) { 
    3419                         if ((strlen($ns[0])>1 && $mailbox == substr($ns[0], 0, -1)) 
     3487                    if ($len = strlen($ns[0])) { 
     3488                        if (($len > 1 && $mailbox == substr($ns[0], 0, -1)) 
    34203489                            || strpos($mailbox, $ns[0]) === 0 
    34213490                        ) { 
  • program/js/common.js

    r65082b3 r3fec695  
    543543}; 
    544544 
    545 // make a string URL safe 
     545// make a string URL safe (and compatible with PHP's rawurlencode()) 
    546546function urlencode(str) 
    547547{ 
    548   return window.encodeURIComponent ? encodeURIComponent(str) : escape(str); 
     548  if (window.encodeURIComponent) 
     549    return encodeURIComponent(str).replace('*', '%2A'); 
     550 
     551  return escape(str) 
     552    .replace('+', '%2B') 
     553    .replace('*', '%2A') 
     554    .replace('/', '%2F') 
     555    .replace('@', '%40'); 
    549556}; 
    550557 
  • program/steps/mail/autocomplete.inc

    recfaed5 r3fec695  
    5555if (!empty($book_types) && strlen($search)) { 
    5656  $contacts  = array(); 
     57  $sort_keys = array(); 
    5758  $books_num = count($book_types); 
    5859  $search_lc = mb_strtolower($search); 
     
    6768        $email_arr = (array)$abook->get_col_values('email', $sql_arr, true); 
    6869        $email_cnt = count($email_arr); 
     70        $idx = 0; 
    6971        foreach ($email_arr as $email) { 
    7072          if (empty($email)) { 
     
    8183          // skip duplicates 
    8284          if (!in_array($contact, $contacts)) { 
    83             $contacts[] = $contact; 
     85            $contacts[]  = $contact; 
     86            $sort_keys[] = sprintf('%s %03d', $sql_arr['name'] , $idx++); 
     87 
    8488            if (count($contacts) >= $MAXNUM) 
    8589              break 2; 
     
    103107        // group (distribution list) with email address(es) 
    104108        if ($group_prop['email']) { 
     109            $idx = 0; 
    105110            foreach ((array)$group_prop['email'] as $email) { 
    106                 $contacts[] = format_email_recipient($email, $group['name']); 
     111                $contacts[]  = format_email_recipient($email, $group['name']); 
     112                $sort_keys[] = sprintf('%s %03d', $group['name'] , $idx++); 
     113 
    107114                if (count($contacts) >= $MAXNUM) 
    108115                  break 2; 
     
    111118        // show group with count 
    112119        else if (($result = $abook->count()) && $result->count) { 
    113           $contacts[] = array('name' => $group['name'] . ' (' . intval($result->count) . ')', 'id' => $group['ID'], 'source' => $id); 
     120          $contacts[]  = array('name' => $group['name'] . ' (' . intval($result->count) . ')', 'id' => $group['ID'], 'source' => $id); 
     121          $sort_keys[] = $group['name']; 
     122 
    114123          if (count($contacts) >= $MAXNUM) 
    115124            break; 
     
    119128  } 
    120129 
    121   usort($contacts, 'contact_results_sort'); 
     130  if (count($contacts)) { 
     131    // sort contacts index 
     132    asort($sort_keys, SORT_LOCALE_STRING); 
     133    // re-sort contacts according to index 
     134    foreach ($sort_keys as $idx => $val) { 
     135      $sort_keys[$idx] = $contacts[$idx]; 
     136    } 
     137    $contacts = array_values($sort_keys); 
     138  } 
    122139} 
    123140 
    124141$OUTPUT->command('ksearch_query_results', $contacts, $search, $sid); 
    125142$OUTPUT->send(); 
    126  
    127  
    128 function contact_results_sort($a, $b) 
    129 { 
    130   $name_a = is_array($a) ? $a['name'] : $a; 
    131   $name_b = is_array($b) ? $b['name'] : $b; 
    132   return strcoll(trim($name_a, '" '), trim($name_b, '" ')); 
    133 } 
    134  
Note: See TracChangeset for help on using the changeset viewer.