Changeset fb6d86b in github


Ignore:
Timestamp:
Nov 23, 2011 1:05:38 PM (18 months ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.8
Children:
e7c445b
Parents:
ef22eee
Message:
  • Fixed bug where similiar folder names were highlighted wrong (#1487860)
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    rae7ac91 rfb6d86b  
    22=========================== 
    33 
     4- Fixed bug where similiar folder names were highlighted wrong (#1487860) 
    45- Fixed bug in handling link with '!' character in it (#1488195) 
    56- Fixed bug where session ID's length was limited to 40 characters (#1488196) 
  • program/include/main.inc

    rb1867b8 rfb6d86b  
    731731/** 
    732732 * Convert the given string into a valid HTML identifier 
    733  * Same functionality as done in app.js with this.identifier_expr 
    734  * 
    735  */ 
    736 function html_identifier($str) 
    737 { 
    738   return asciiwords($str, true, '_'); 
     733 * Same functionality as done in app.js with rcube_webmail.html_identifier() 
     734 */ 
     735function html_identifier($str, $encode=false) 
     736{ 
     737  if ($encode) 
     738    return rtrim(strtr(base64_encode($str), '+/', '-_'), '='); 
     739  else 
     740    return asciiwords($str, true, '_'); 
    739741} 
    740742 
     
    13321334 
    13331335    // make folder name safe for ids and class names 
    1334     $folder_id = html_identifier($folder['id']); 
     1336    $folder_id = html_identifier($folder['id'], true); 
    13351337    $classes = array('mailbox'); 
    13361338 
  • program/js/app.js

    r4693fe1 rfb6d86b  
    12031203  }; 
    12041204 
     1205  this.html_identifier = function(str, encode) 
     1206  { 
     1207    str = String(str); 
     1208    if (encode) 
     1209      return Base64.encode(str).replace(/=+$/, '').replace(/\+/g, '-').replace(/\//g, '_'); 
     1210    else 
     1211      return str.replace(this.identifier_expr, '_'); 
     1212  }; 
     1213 
     1214  this.html_identifier_decode = function(str) 
     1215  { 
     1216    str = String(str).replace(/-/g, '+').replace(/_/g, '/'); 
     1217 
     1218    while (str.length % 4) str += '='; 
     1219 
     1220    return Base64.decode(str); 
     1221  }; 
     1222 
    12051223 
    12061224  /*********************************************************/ 
     
    13601378  }; 
    13611379 
    1362   this.collapse_folder = function(id) 
    1363   { 
    1364     var li = this.get_folder_li(id), 
     1380  this.collapse_folder = function(name) 
     1381  { 
     1382    var li = this.get_folder_li(name, '', true), 
    13651383      div = $(li.getElementsByTagName('div')[0]); 
    13661384 
     
    13731391      ul.show(); 
    13741392      div.removeClass('collapsed').addClass('expanded'); 
    1375       var reg = new RegExp('&'+urlencode(id)+'&'); 
     1393      var reg = new RegExp('&'+urlencode(name)+'&'); 
    13761394      this.env.collapsed_folders = this.env.collapsed_folders.replace(reg, ''); 
    13771395    } 
     
    13791397      ul.hide(); 
    13801398      div.removeClass('expanded').addClass('collapsed'); 
    1381       this.env.collapsed_folders = this.env.collapsed_folders+'&'+urlencode(id)+'&'; 
     1399      this.env.collapsed_folders = this.env.collapsed_folders+'&'+urlencode(name)+'&'; 
    13821400 
    13831401      // select parent folder if one of its childs is currently selected 
    1384       if (this.env.mailbox.indexOf(id + this.env.delimiter) == 0) 
    1385         this.command('list', id); 
     1402      if (this.env.mailbox.indexOf(name + this.env.delimiter) == 0) 
     1403        this.command('list', name); 
    13861404    } 
    13871405 
     
    13961414 
    13971415    this.command('save-pref', { name: 'collapsed_folders', value: this.env.collapsed_folders }); 
    1398     this.set_unread_count_display(id, false); 
     1416    this.set_unread_count_display(name, false); 
    13991417  }; 
    14001418 
     
    19892007      url += '&_refresh=1'; 
    19902008 
    1991     this.select_folder(mbox); 
     2009    this.select_folder(mbox, '', true); 
    19922010    this.env.mailbox = mbox; 
    19932011 
     
    40674085    var c, row, list = this.contact_list; 
    40684086 
    4069     cid = String(cid).replace(this.identifier_expr, '_'); 
     4087    cid = this.html_identifier(cid); 
    40704088 
    40714089    // when in searching mode, concat cid with the source name 
     
    40834101      // cid change 
    40844102      if (newcid) { 
    4085         newcid = String(newcid).replace(this.identifier_expr, '_'); 
     4103        newcid = this.html_identifier(newcid); 
    40864104        row.id = 'rcmrow' + newcid; 
    40874105        list.remove_row(cid); 
     
    41024120      row = document.createElement('tr'); 
    41034121 
    4104     row.id = 'rcmrow'+String(cid).replace(this.identifier_expr, '_'); 
     4122    row.id = 'rcmrow'+this.html_identifier(cid); 
    41054123    row.className = 'contact'; 
    41064124 
     
    42844302        .click(function() { return rcmail.command('listgroup', prop, this); }) 
    42854303        .html(prop.name), 
    4286       li = $('<li>').attr({id: 'rcmli'+key.replace(this.identifier_expr, '_'), 'class': 'contactgroup'}) 
     4304      li = $('<li>').attr({id: 'rcmli'+this.html_identifier(key), 'class': 'contactgroup'}) 
    42874305        .append(link); 
    42884306 
     
    43074325        newprop = $.extend({}, prop);; 
    43084326 
    4309       li.id = String('rcmli'+newkey).replace(this.identifier_expr, '_'); 
     4327      li.id = 'rcmli' + this.html_identifier(newkey); 
    43104328      this.env.contactfolders[newkey] = this.env.contactfolders[key]; 
    43114329      this.env.contactfolders[newkey].id = prop.newid; 
     
    43394357    var row, name = prop.name.toUpperCase(), 
    43404358      sibling = this.get_folder_li(prop.source), 
    4341       prefix = 'rcmliG'+(prop.source).replace(this.identifier_expr, '_'); 
     4359      prefix = 'rcmliG' + this.html_identifier(prop.source); 
    43424360 
    43434361    // When renaming groups, we need to remove it from DOM and insert it in the proper place 
     
    45724590        .click(function() { return rcmail.command('listsearch', id, this); }) 
    45734591        .html(name), 
    4574       li = $('<li>').attr({id: 'rcmli'+key.replace(this.identifier_expr, '_'), 'class': 'contactsearch'}) 
     4592      li = $('<li>').attr({id: 'rcmli' + this.html_identifier(key), 'class': 'contactsearch'}) 
    45754593        .append(link), 
    45764594      prop = {name:name, id:id, li:li[0]}; 
     
    53005318      // save message in order to display after page loaded 
    53015319      if (type != 'loading') 
    5302         this.pending_message = new Array(msg, type, timeout); 
     5320        this.pending_message = [msg, type, timeout]; 
    53035321      return false; 
    53045322    } 
     
    53075325 
    53085326    var ref = this, 
    5309       key = String(msg).replace(this.identifier_expr, '_'), 
     5327      key = this.html_identifier(msg), 
    53105328      date = new Date(), 
    53115329      id = type + date.getTime(); 
     
    54005418 
    54015419  // mark a mailbox as selected and set environment variable 
    5402   this.select_folder = function(name, prefix) 
     5420  this.select_folder = function(name, prefix, encode) 
    54035421  { 
    54045422    if (this.gui_objects.folderlist) { 
     
    54085426        current_li.removeClass('selected').addClass('unfocused'); 
    54095427      } 
    5410       if ((target_li = this.get_folder_li(name, prefix))) { 
     5428      if ((target_li = this.get_folder_li(name, prefix, encode))) { 
    54115429        $(target_li).removeClass('unfocused').addClass('selected'); 
    54125430      } 
     
    54185436 
    54195437  // helper method to find a folder list item 
    5420   this.get_folder_li = function(name, prefix) 
     5438  this.get_folder_li = function(name, prefix, encode) 
    54215439  { 
    54225440    if (!prefix) 
     
    54245442 
    54255443    if (this.gui_objects.folderlist) { 
    5426       name = String(name).replace(this.identifier_expr, '_'); 
     5444      name = this.html_identifier(name, encode); 
    54275445      return document.getElementById(prefix+name); 
    54285446    } 
     
    55385556    var reg, link, text_obj, item, mycount, childcount, div; 
    55395557 
    5540     if (item = this.get_folder_li(mbox)) { 
     5558    if (item = this.get_folder_li(mbox, '', true)) { 
    55415559      mycount = this.env.unread_counts[mbox] ? this.env.unread_counts[mbox] : 0; 
    55425560      link = $(item).children('a').eq(0); 
     
    55505568          div.className.match(/collapsed/)) { 
    55515569        // add children's counters 
    5552         for (var k in this.env.unread_counts)  
     5570        for (var k in this.env.unread_counts) 
    55535571          if (k.indexOf(mbox + this.env.delimiter) == 0) 
    55545572            childcount += this.env.unread_counts[k]; 
  • program/js/common.js

    rbe58b50 rfb6d86b  
    712712  } 
    713713} 
     714 
     715// This code was written by Tyler Akins and has been placed in the 
     716// public domain.  It would be nice if you left this header intact. 
     717// Base64 code from Tyler Akins -- http://rumkin.com 
     718var Base64 = (function () { 
     719  var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 
     720 
     721  var obj = { 
     722    /** 
     723     * Encodes a string in base64 
     724     * @param {String} input The string to encode in base64. 
     725     */ 
     726    encode: function (input) { 
     727      if (typeof(window.btoa) === 'function') 
     728        return btoa(input); 
     729 
     730      var chr1, chr2, chr3, enc1, enc2, enc3, enc4, i = 0, output = '', len = input.length; 
     731 
     732      do { 
     733        chr1 = input.charCodeAt(i++); 
     734        chr2 = input.charCodeAt(i++); 
     735        chr3 = input.charCodeAt(i++); 
     736 
     737        enc1 = chr1 >> 2; 
     738        enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); 
     739        enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); 
     740        enc4 = chr3 & 63; 
     741 
     742        if (isNaN(chr2)) 
     743          enc3 = enc4 = 64; 
     744        else if (isNaN(chr3)) 
     745          enc4 = 64; 
     746 
     747        output = output 
     748          + keyStr.charAt(enc1) + keyStr.charAt(enc2) 
     749          + keyStr.charAt(enc3) + keyStr.charAt(enc4); 
     750      } while (i < len); 
     751 
     752      return output; 
     753    }, 
     754 
     755    /** 
     756     * Decodes a base64 string. 
     757     * @param {String} input The string to decode. 
     758     */ 
     759    decode: function (input) { 
     760      if (typeof(window.atob) === 'function') 
     761         return atob(input); 
     762 
     763      var chr1, chr2, chr3, enc1, enc2, enc3, enc4, len, i = 0, output = ''; 
     764 
     765      // remove all characters that are not A-Z, a-z, 0-9, +, /, or = 
     766      input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); 
     767      len = input.length; 
     768 
     769      do { 
     770        enc1 = keyStr.indexOf(input.charAt(i++)); 
     771        enc2 = keyStr.indexOf(input.charAt(i++)); 
     772        enc3 = keyStr.indexOf(input.charAt(i++)); 
     773        enc4 = keyStr.indexOf(input.charAt(i++)); 
     774 
     775        chr1 = (enc1 << 2) | (enc2 >> 4); 
     776        chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); 
     777        chr3 = ((enc3 & 3) << 6) | enc4; 
     778 
     779        output = output + String.fromCharCode(chr1); 
     780 
     781        if (enc3 != 64) 
     782          output = output + String.fromCharCode(chr2); 
     783        if (enc4 != 64) 
     784          output = output + String.fromCharCode(chr3); 
     785      } while (i < len); 
     786 
     787      return output; 
     788    } 
     789  }; 
     790 
     791  return obj; 
     792})(); 
Note: See TracChangeset for help on using the changeset viewer.