Ticket #1484313 (closed Patches: fixed)

Opened 17 months ago

Last modified 6 months ago

Mailbox name not quoted when used in URL - patch available

Reported by: Emil Wojak Owned by: thomasb
Priority: 2 Milestone: 0.1.1
Component: Core functionality Version: svn-trunk
Severity: major Keywords:
Cc:

Description

Whenever a mailbox's name has some non-ASCII characters encoded in UTF-7, it then contains an ampersand, which should be encoded each time it's used in URL. There are some variables both in PHP and JS code, that are used literally, which causes some failures when dealing with such mailboxes.

In particular, you can't fetch attachments.

So here's the resolution:

Index: program/js/app.js
===================================================================
--- program/js/app.js   (wersja 536)
+++ program/js/app.js   (kopia robocza)
@@ -668,7 +668,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)
@@ -1948,7 +1948,7 @@
       {
       this.message_list.clear();
       this.set_busy(true, 'searching');
-      this.http_request('search', '_search='+value+'&_mbox='+mbox, true);
+      this.http_request('search', '_search='+value+'&_mbox='+urlencode(mbox), true);
       }
     return true;
     };
Index: program/steps/mail/func.inc
===================================================================
--- program/steps/mail/func.inc (wersja 536)
+++ program/steps/mail/func.inc (kopia robocza)
@@ -59,7 +59,7 @@

 // define url for getting message parts
 if (strlen($_GET['_uid']))
-  $GET_URL = sprintf('%s&_action=get&_mbox=%s&_uid=%d', $COMM_PATH, $IMAP->get_mailbox_name(), get_input_value('_uid', RCUBE_INPUT_GET));
+  $GET_URL = sprintf('%s&_action=get&_mbox=%s&_uid=%d', $COMM_PATH, urlencode($IMAP->get_mailbox_name()), get_input_value('_uid', RCUBE_INPUT_GET));


 // set current mailbox in client environment

Attachments

bugfix1484313.patch (1.5 kB) - added by Emil Wojak 17 months ago.
Solution
mboxnames.jpg (63.5 kB) - added by lancey 6 months ago.
E-mail with attachments, open from a folder with an & and non-ASCII chars in it
mboxnamesbug.diff (1.2 kB) - added by lancey 6 months ago.
Patch against current SVN (v1107)

Change History

  Changed 17 months ago by Saiph

  • priority changed from 8 to 2

Changed 17 months ago by Emil Wojak

Solution

  Changed 6 months ago by seansan

  • summary changed from Mailbox name not quoted when used in URL to Mailbox name not quoted when used in URL - patch available
  • milestone set to 0.1.1

review in 0.1.1 - patch available

Changed 6 months ago by lancey

E-mail with attachments, open from a folder with an & and non-ASCII chars in it

follow-up: ↓ 4   Changed 6 months ago by lancey

I can't replicate the problem with SVN v1107. Indeed, there are places where we don't URLencode the this.env.mailbox variable, so it's possible that problems appear. Patch added. (Seems like the second change to app.js was already done in SVN)

Changed 6 months ago by lancey

Patch against current SVN (v1107)

in reply to: ↑ 3   Changed 6 months ago by memoryhole

Replying to lancey:

I can't replicate the problem with SVN v1107. Indeed, there are places where we don't URLencode the this.env.mailbox variable, so it's possible that problems appear. Patch added. (Seems like the second change to app.js was already done in SVN)

Agreed that there are lots of potential problems here. You left out one other instance where mbox needs to be urlencode'd---around line 2035 or so of program/js/app.js, the line that looks like this:

  this.http_request('search', '_q='+urlencode(value)+(this.env.mailbox ? '&_mbox='+this.env.mailbox : '')+(this.env.source ? urlencode(this.env.source) : ''), true);

...should look like this:

  this.http_request('search', '_q='+urlencode(value)+(this.env.mailbox ? '&_mbox='+urlencode(this.env.mailbox) : '')+(this.env.source ? urlencode(this.env.source) : ''), true);

  Changed 6 months ago by thomasb

  • owner set to thomasb

  Changed 6 months ago by thomasb

  • status changed from new to closed
  • resolution set to fixed

Committed in r1189

Note: See TracTickets for help on using tickets.