Subject: Folder name space and the '&' character

From: George Lindholm <[email-masked]>
Date: Thu, 24 Jul 2003 12:58:38 -0700

Hi,
   lets try this again.

I'm having problems with folders containg the '&' character (which is causing our Webmail users some grief).

I crated two files named 'b &- d' and 'C & D' and then did a:

       Folder root = store.getDefaultFolder().getFolder("mail/amp");
       Folder[] folders = root.list("%");
       for (int i = 0; i < folders.length; i++) {
         try {
           System.err.println(folders[i].getFullName());
           if (!folders[i].exists()) {
             System.err.println(" (doesn't exist?)");
           }
           else {
             folders[i].open(Folder.READ_ONLY);
             folders[i].close(false);
           }
         } catch (javax.mail.MessagingException me) {
           System.err.println(me);
         }

with the following output:

DEBUG: setDebug: JavaMail version 1.3.1
* OK [CAPABILITY IMAP4REV1 LOGIN-REFERRALS STARTTLS AUTH=LOGIN] localhost IMAP4rev1 2003.338 at Thu, 24 Jul 2003 12:34:16 -0700 (PDT)
A0 CAPABILITY
* CAPABILITY IMAP4REV1 IDLE NAMESPACE MAILBOX-REFERRALS BINARY UNSELECT SCAN SORT THREAD=REFERENCES THREAD=ORDEREDSUBJECT MULTIAPPEND LOGIN-REFERRALS 
STARTTLS AUTH=LOGIN
A0 OK CAPABILITY completed
A1 OK [CAPABILITY IMAP4REV1 IDLE NAMESPACE MAILBOX-REFERRALS BINARY UNSELECT SCAN SORT THREAD=REFERENCES THREAD=ORDEREDSUBJECT MULTIAPPEND] User xxx 
authenticated
A2 LIST "" mail/amp
* LIST (\NoSelect) "/" mail/amp
A2 OK LIST completed
A3 LIST "" "mail/amp/%"
* LIST (\NoSelect) "/" mail/amp/
* LIST (\NoInferiors \UnMarked) "/" "mail/amp/b &- d"
* LIST (\NoInferiors \UnMarked) "/" "mail/amp/C & D"
A3 OK LIST completed
mail/amp/b & d
A4 LIST "" "mail/amp/b &- d"
* LIST (\NoInferiors \UnMarked) "/" "mail/amp/b &- d"
A4 OK LIST completed
DEBUG: connection available -- size: 1
A5 EXAMINE "mail/amp/b &- d"
* 0 EXISTS
* 0 RECENT
* OK [UIDVALIDITY 1059075256] UID validity status
* OK [UIDNEXT 1] Predicted next UID
* FLAGS (\Answered \Flagged \Deleted \Draft \Seen)
* OK [PERMANENTFLAGS ()] Permanent flags
A5 OK [READ-ONLY] EXAMINE completed
A6 CLOSE
A6 OK CLOSE completed
DEBUG: added an Authenticated connection -- size: 1

mail/amp/C
A7 LIST "" "mail/amp/C "
A7 OK LIST completed
  (doesn't exist?)

As you can see, the folder name of 'b &- d' comes out as 'b & d' and of 'C & D' comes out as 'C '.
This makes in difficult, if not impossible to access the folders.

I also tried this with pine (no problems), mozilla mail (folders appears as 'b & e' and 'C D'),
and KMail (folders appears as 'b & e' and 'C D', but I can' access the messages in
the folders)

And if I read RFC3501, section 5.1.3, correctly, isn't the imap server supposed to escape the
'&' properly since this is the signal to the client that the string is BASE64 encoded?

So what is going on here, and how do I fix/get around this problem.

Thanks

     George
-- 
[email-masked]       ITServices, UBC
Programmer/Analyst

phone:    604.822.4375       fax:      604.822.5116

-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Mark Crispin <[email-masked]>
Date: Mon, 18 Aug 2003 15:31:51 -0700 (Pacific Daylight Time)

> I crated two files named 'b &- d' and 'C & D' and then did a:

"C & D" is not a valid mailbox name.

"b &- d" is a mailbox name which should display as "b & d".

> This makes in difficult, if not impossible to access the folders.

Yup...

> '&' properly since this is the signal to the client that the string is BASE64 encoded?

There is no requirement for the IMAP server to do any escaping.  In UW
imapd, the file names are the same as the mailbox names.  UW imapd won't
protect you if you create a file with a name that is an invalid mailbox
name.  The client is responsible for not doing that.

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.
Si vis pacem, para bellum.

---

From: George Lindholm <[email-masked]>
Date: Wed, 20 Aug 2003 09:45:29 -0700

> name.  The client is responsible for not doing that.

We are moving away from local filesystem access to the
folders to imap access, and unfortunately, pine allows you
to create folders with '&' (as well as '*' and '%") so we
have a number of users out there that have created folders
with these characters of the years that now can no longer
access them.

    George