From c5418bd82c081d7c89012f2d6e497535224ad29d Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sun, 09 Mar 2008 13:54:20 -0400
Subject: [PATCH] Correctly encode mailbox names (#1484313)

---
 program/js/app.js |   65 +++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 27 deletions(-)

diff --git a/program/js/app.js b/program/js/app.js
index 20cd67b..ec5fac3 100644
--- a/program/js/app.js
+++ b/program/js/app.js
@@ -311,8 +311,8 @@
         break;
 
       case 'login':
-        var input_user = rcube_find_object('_user');
-        var input_pass = rcube_find_object('_pass');
+        var input_user = rcube_find_object('rcmloginuser');
+        var input_pass = rcube_find_object('rcmloginpwd');
         if (input_user)
           input_user.onkeypress = function(e){ return rcmail.login_user_keypress(e); };
         if (input_user && input_user.value=='')
@@ -695,7 +695,7 @@
         if (props._row.uid)
           {
           uid = props._row.uid;
-          this.message_list.dont_select = true;
+          
           // toggle read/unread
           if (this.message_list.rows[uid].deleted) {
             flag = 'undelete';
@@ -712,7 +712,7 @@
         break;
 
       case 'load-attachment':
-        var qstring = '_mbox='+this.env.mailbox+'&_uid='+this.env.uid+'&_part='+props.part;
+        var qstring = '_mbox='+urlencode(this.env.mailbox)+'&_uid='+this.env.uid+'&_part='+props.part;
         
         // open attachment in frame if it's of a supported mimetype
         if (this.env.uid && props.mimetype && find_in_array(props.mimetype, this.mimetypes)>=0)
@@ -886,11 +886,15 @@
       case 'print':
         var uid;
         if (uid = this.get_single_uid())
-          {
+        {
           ref.printwin = window.open(this.env.comm_path+'&_action=print&_uid='+uid+'&_mbox='+urlencode(this.env.mailbox)+(this.env.safemode ? '&_safe=1' : ''));
           if (this.printwin)
+          {
             setTimeout(function(){ ref.printwin.focus(); }, 20);
+            if (this.env.action != 'show')
+              this.toggle_read_status('read', [uid]);
           }
+        }
         break;
 
       case 'viewsource':
@@ -1096,10 +1100,6 @@
       this.unfocus_folder(id);
       this.command('moveto', id);
       }
-
-    // Hide message command buttons until a message is selected 
-    this.enable_command('reply', 'reply-all', 'forward', 'delete', 'mark', 'print', false); 
-    return false;
     };
 
   this.click_on_list = function(e)
@@ -1383,11 +1383,8 @@
   this.move_messages = function(mbox)
     {
     // exit if current or no mailbox specified or if selection is empty
-    if (!mbox || !this.env.uid || mbox==this.env.mailbox)
-      {
-      if (!this.message_list || !this.message_list.get_selection().length)
-        return;
-      }
+    if (!mbox || mbox == this.env.mailbox || (!this.env.uid && (!this.message_list || !this.message_list.get_selection().length)))
+      return;
 
     var lock = false;
     var add_url = '&_target_mbox='+urlencode(mbox)+'&_from='+(this.env.action ? this.env.action : '');
@@ -1400,6 +1397,9 @@
       }
     else
       this.show_contentframe(false);
+
+    // Hide message command buttons until a message is selected
+    this.enable_command('reply', 'reply-all', 'forward', 'delete', 'mark', 'print', false);
 
     this._with_selected_messages('moveto', lock, add_url);
     };
@@ -1695,11 +1695,14 @@
     {
     // check input fields
     var input_to = rcube_find_object('_to');
+    var input_cc = rcube_find_object('_cc');
+    var input_bcc = rcube_find_object('_bcc');
     var input_subject = rcube_find_object('_subject');
     var input_message = rcube_find_object('_message');
 
     // check for empty recipient
-    if (input_to && !rcube_check_email(input_to.value.replace(/^\s+/, '').replace(/[\s,;]+$/, ''), true))
+    var recipients = input_to.value ? input_to.value : (input_cc.value ? input_cc.value : input_bcc.value);
+    if (!rcube_check_email(recipients.replace(/^\s+/, '').replace(/[\s,;]+$/, ''), true))
       {
       alert(this.get_label('norecipientwarning'));
       input_to.focus();
@@ -2007,7 +2010,7 @@
       // reset vars
       this.env.current_page = 1;
       this.set_busy(true, 'searching');
-      this.http_request('search', '_q='+urlencode(value)+(this.env.mailbox ? '&_mbox='+this.env.mailbox : '')+(this.env.source ? '&_source='+urlencode(this.env.source) : ''), true);
+      this.http_request('search', '_q='+urlencode(value)+(this.env.mailbox ? '&_mbox='+urlencode(this.env.mailbox) : '')+(this.env.source ? '&_source='+urlencode(this.env.source) : ''), true);
       }
     return true;
     };
@@ -2695,8 +2698,14 @@
 
     var refrow, form;
     var tbody = this.gui_objects.subscriptionlist.tBodies[0];
-    var id = replace && replace.id ? replace.id : 'rcmrow'+(tbody.childNodes.length+1);
+    var id = 'rcmrow'+(tbody.childNodes.length+1);
     var selection = this.subscription_list.get_single_selection();
+    
+    if (replace && replace.id)
+    {
+      id = replace.id;
+      refid = replace.id;
+    }
 
     if (!id || !(refrow = document.getElementById(refid)))
       {
@@ -2713,18 +2722,23 @@
       else
         tbody.appendChild(row);
       }
-
+    
     // add to folder/row-ID map
     this.env.subscriptionrows[row.id] = [name, display_name];
 
     // set folder name
     row.cells[0].innerHTML = display_name;
-    if (row.cells[1] && row.cells[1].firstChild.tagName=='INPUT')
+    
+    // set messages count to zero
+    if (!replace)
+      row.cells[1].innerHTML = '*';
+    
+    if (!replace && row.cells[2] && row.cells[2].firstChild.tagName=='INPUT')
       {
-      row.cells[1].firstChild.value = name;
-      row.cells[1].firstChild.checked = true;
+      row.cells[2].firstChild.value = name;
+      row.cells[2].firstChild.checked = true;
       }
-       
+    
     // add new folder to rename-folder list and clear input field
     if (!replace && (form = this.gui_objects.editform))
       {
@@ -3269,11 +3283,8 @@
     if (!this.gui_objects.mailboxlist)
       return false;
 
-    var reg, text_obj;
-    var item = this.get_folder_li(mbox);
-    mbox = String(mbox).toLowerCase().replace(this.identifier_expr, '');
-
-    if (item && item.className && item.className.indexOf('mailbox '+mbox)>=0)
+    var reg, text_obj, item;
+    if (item = this.get_folder_li(mbox))
       {
       // set new text
       text_obj = item.firstChild;

--
Gitblit v1.9.1