Changeset fb6d86b in github
- Timestamp:
- Nov 23, 2011 1:05:38 PM (18 months ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.8
- Children:
- e7c445b
- Parents:
- ef22eee
- Files:
-
- 4 edited
-
CHANGELOG (modified) (1 diff)
-
program/include/main.inc (modified) (2 diffs)
-
program/js/app.js (modified) (21 diffs)
-
program/js/common.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
rae7ac91 rfb6d86b 2 2 =========================== 3 3 4 - Fixed bug where similiar folder names were highlighted wrong (#1487860) 4 5 - Fixed bug in handling link with '!' character in it (#1488195) 5 6 - Fixed bug where session ID's length was limited to 40 characters (#1488196) -
program/include/main.inc
rb1867b8 rfb6d86b 731 731 /** 732 732 * 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 */ 735 function html_identifier($str, $encode=false) 736 { 737 if ($encode) 738 return rtrim(strtr(base64_encode($str), '+/', '-_'), '='); 739 else 740 return asciiwords($str, true, '_'); 739 741 } 740 742 … … 1332 1334 1333 1335 // make folder name safe for ids and class names 1334 $folder_id = html_identifier($folder['id'] );1336 $folder_id = html_identifier($folder['id'], true); 1335 1337 $classes = array('mailbox'); 1336 1338 -
program/js/app.js
r4693fe1 rfb6d86b 1203 1203 }; 1204 1204 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 1205 1223 1206 1224 /*********************************************************/ … … 1360 1378 }; 1361 1379 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), 1365 1383 div = $(li.getElementsByTagName('div')[0]); 1366 1384 … … 1373 1391 ul.show(); 1374 1392 div.removeClass('collapsed').addClass('expanded'); 1375 var reg = new RegExp('&'+urlencode( id)+'&');1393 var reg = new RegExp('&'+urlencode(name)+'&'); 1376 1394 this.env.collapsed_folders = this.env.collapsed_folders.replace(reg, ''); 1377 1395 } … … 1379 1397 ul.hide(); 1380 1398 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)+'&'; 1382 1400 1383 1401 // 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); 1386 1404 } 1387 1405 … … 1396 1414 1397 1415 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); 1399 1417 }; 1400 1418 … … 1989 2007 url += '&_refresh=1'; 1990 2008 1991 this.select_folder(mbox );2009 this.select_folder(mbox, '', true); 1992 2010 this.env.mailbox = mbox; 1993 2011 … … 4067 4085 var c, row, list = this.contact_list; 4068 4086 4069 cid = String(cid).replace(this.identifier_expr, '_');4087 cid = this.html_identifier(cid); 4070 4088 4071 4089 // when in searching mode, concat cid with the source name … … 4083 4101 // cid change 4084 4102 if (newcid) { 4085 newcid = String(newcid).replace(this.identifier_expr, '_');4103 newcid = this.html_identifier(newcid); 4086 4104 row.id = 'rcmrow' + newcid; 4087 4105 list.remove_row(cid); … … 4102 4120 row = document.createElement('tr'); 4103 4121 4104 row.id = 'rcmrow'+ String(cid).replace(this.identifier_expr, '_');4122 row.id = 'rcmrow'+this.html_identifier(cid); 4105 4123 row.className = 'contact'; 4106 4124 … … 4284 4302 .click(function() { return rcmail.command('listgroup', prop, this); }) 4285 4303 .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'}) 4287 4305 .append(link); 4288 4306 … … 4307 4325 newprop = $.extend({}, prop);; 4308 4326 4309 li.id = String('rcmli'+newkey).replace(this.identifier_expr, '_');4327 li.id = 'rcmli' + this.html_identifier(newkey); 4310 4328 this.env.contactfolders[newkey] = this.env.contactfolders[key]; 4311 4329 this.env.contactfolders[newkey].id = prop.newid; … … 4339 4357 var row, name = prop.name.toUpperCase(), 4340 4358 sibling = this.get_folder_li(prop.source), 4341 prefix = 'rcmliG' +(prop.source).replace(this.identifier_expr, '_');4359 prefix = 'rcmliG' + this.html_identifier(prop.source); 4342 4360 4343 4361 // When renaming groups, we need to remove it from DOM and insert it in the proper place … … 4572 4590 .click(function() { return rcmail.command('listsearch', id, this); }) 4573 4591 .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'}) 4575 4593 .append(link), 4576 4594 prop = {name:name, id:id, li:li[0]}; … … 5300 5318 // save message in order to display after page loaded 5301 5319 if (type != 'loading') 5302 this.pending_message = new Array(msg, type, timeout);5320 this.pending_message = [msg, type, timeout]; 5303 5321 return false; 5304 5322 } … … 5307 5325 5308 5326 var ref = this, 5309 key = String(msg).replace(this.identifier_expr, '_'),5327 key = this.html_identifier(msg), 5310 5328 date = new Date(), 5311 5329 id = type + date.getTime(); … … 5400 5418 5401 5419 // mark a mailbox as selected and set environment variable 5402 this.select_folder = function(name, prefix )5420 this.select_folder = function(name, prefix, encode) 5403 5421 { 5404 5422 if (this.gui_objects.folderlist) { … … 5408 5426 current_li.removeClass('selected').addClass('unfocused'); 5409 5427 } 5410 if ((target_li = this.get_folder_li(name, prefix ))) {5428 if ((target_li = this.get_folder_li(name, prefix, encode))) { 5411 5429 $(target_li).removeClass('unfocused').addClass('selected'); 5412 5430 } … … 5418 5436 5419 5437 // 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) 5421 5439 { 5422 5440 if (!prefix) … … 5424 5442 5425 5443 if (this.gui_objects.folderlist) { 5426 name = String(name).replace(this.identifier_expr, '_');5444 name = this.html_identifier(name, encode); 5427 5445 return document.getElementById(prefix+name); 5428 5446 } … … 5538 5556 var reg, link, text_obj, item, mycount, childcount, div; 5539 5557 5540 if (item = this.get_folder_li(mbox )) {5558 if (item = this.get_folder_li(mbox, '', true)) { 5541 5559 mycount = this.env.unread_counts[mbox] ? this.env.unread_counts[mbox] : 0; 5542 5560 link = $(item).children('a').eq(0); … … 5550 5568 div.className.match(/collapsed/)) { 5551 5569 // add children's counters 5552 for (var k in this.env.unread_counts) 5570 for (var k in this.env.unread_counts) 5553 5571 if (k.indexOf(mbox + this.env.delimiter) == 0) 5554 5572 childcount += this.env.unread_counts[k]; -
program/js/common.js
rbe58b50 rfb6d86b 712 712 } 713 713 } 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 718 var 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.
