Ticket #1484467 (closed Bugs: wontfix)

Opened 17 months ago

Last modified 4 months ago

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?

Change History

Changed 15 months ago by till

  • owner set to till
  • status changed from new to assigned
  • component changed from Client to PHP backend
  • milestone set to 0.1-rc2

Changed 15 months ago by till

I know it's been a while, but I'd like to integrate your work into Roundcube.

Changed 14 months ago by thomasb

  • milestone changed from 0.1-rc2 to 0.1-stable

I can't see any wrong behavior of imap.inc str_replace("\"", "", does not remove backslashes but quotes.

Please suggest a concrete fix to make it work with your Domino server because we're unable to test it.

Changed 14 months ago by seansan

Maybe if we identify the delimiter first we can clean up the code accordingly?

  /**
   * Returns the delimiter that is used by the IMAP server for folder separation
   *
   * @return  string  Delimiter string
   * @access  public
   */
  function get_hierarchy_delimiter(

Changed 10 months ago by coolfactor

Just as a precautionary measure, and for clarity, it might be an idea to change the code to using single quotes around the double-quote.

str_replace('"', '', $a[count($a)-1])

In PHP, it's safe to use single quotes in most cases, especially when parsing of the string is not needed/wanted.

Changed 10 months ago by till

  • status changed from assigned to closed
  • resolution set to wontfix

I'm closing this bug because a) there is no feedback, b) none of us has access to this mailserver and c) I see nothing in imap.inc where this delimiter would be stripped from.

Note: See TracTickets for help on using tickets.