Ticket #1484467 (closed Bugs: wontfix)
Subfolders not working on IMAP system using backslash separator
| Reported by: | davidg | Owned by: | till |
|---|---|---|---|
| Priority: | 5 | Milestone: | 0.1-stable |
| Component: | PHP backend | Version: | 0.1-rc1 |
| Severity: | normal | Keywords: | hierarchical folders subfolders quoted literal string |
| Cc: |
Description
Domino 5.0/Lotus Notes uses the backslash (\) character as the mailbox hierarchy delimiter, however RoundCube appears to simply remove all such characters from mailbox names, resulting in a mailbox name of "folder 1\subfolder 2" appearing as "folder 1subfolder 2" and being unusable.
A LIST "" "*" command sent to the server returns lines such as:
* LIST () "\\" {20}
folder 1\subfolder 2
From reading RFC3501, this appears legal, with the quoted string "\\" needing to be converted ("\"), and the literal string (second line) taken as is without conversion ("folder 1\subfolder 2")
RoundCube, however, indiscriminately removes all backslashes from both the mailbox name and the delimiter, leaving a null delimiter ("") and a mailbox name without a delimiter ("folder 1subfolder 2"). Here's the code:
[program/lib/imap.inc]
1725 $folder = str_replace("\"", "", $a[count($a)-1]);
. . .
1728 $delim = str_replace("\"", "", $a[count($a)-2]);
I don't know if this is the only place this is done; I suspect not and will do some more looking.
While this is specifically affecting hierarchical folders, it looks to be a more general problem with how strings are being handled. Proper behavior would be to leave literal strings, like the second line of the above example, unchanged. Quoted strings, like "\\" in the first line, need to have double-backslashes converted into singles, and single backslashes removed (leaving the characters they are protecting intact).
The code currently takes some shortcuts, treating both quoted and literal strings the same -- as literal strings, with the exception of a blanket removal of all backslashes. In particular, iil_MultLine simply adds quotes around the literal and treats it like a quoted string, ignoring the possibility of characters being present that might need special treatment, such as the backslash.
The simplest solution would probably be for iil_MultLine to add a backslash in front of any backslashes in the literal string (and perhaps in front of other special characters like " characters), and then have a routine to remove them again, properly converting double-backslashes into single ones, in place of the str_replace function currently used.
BTW, I could probably fix some of this stuff and will for my own purposes if need be. Is submitting a ticket like this the best way to help RoundCube development, or what would be involved in becoming a developer and/or submitting code changes more directly?
