changeset 3505:0e05687892dc HEAD

Added tb-extra-mailbox-sep IMAP workaround.
author Timo Sirainen <tss@iki.fi>
date Fri, 22 Jul 2005 17:20:44 +0300
parents ee0e39cf4ca5
children c17e810208a6
files dovecot-example.conf src/imap/cmd-delete.c src/imap/cmd-subscribe.c src/imap/common.h src/imap/main.c
diffstat 5 files changed, 29 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/dovecot-example.conf	Fri Jul 22 15:42:57 2005 +0300
+++ b/dovecot-example.conf	Fri Jul 22 17:20:44 2005 +0300
@@ -429,6 +429,13 @@
   #     workaround makes sure that Netscape never breaks by adding the line if
   #     it doesn't exist. This is done only for FETCH BODY[HEADER.FIELDS..]
   #     commands. Note that RFC says this shouldn't be done.
+  #   tb-extra-mailbox-sep:
+  #     With mbox storage a mailbox can contain either mails or submailboxes,
+  #     but not both. Submailboxes-only-mailbox is created by CREATE box/
+  #     command. Thunderbird unfortunately keeps the extra slash also for
+  #     SUBSCRIBE, UNSUBSCRIBE and DELETE commands, causing Dovecot to fail
+  #     with "Invalid mailbox name" error. This workaround strips away the
+  #     extra slash.
   #imap_client_workarounds = outlook-idle
 }
   
--- a/src/imap/cmd-delete.c	Fri Jul 22 15:42:57 2005 +0300
+++ b/src/imap/cmd-delete.c	Fri Jul 22 17:20:44 2005 +0300
@@ -34,6 +34,13 @@
 			return TRUE;
 	}
 
+	if ((client_workarounds & WORKAROUND_TB_EXTRA_MAILBOX_SEP) != 0 &&
+	    *name != '\0' &&
+	    name[strlen(name)-1] == mail_storage_get_hierarchy_sep(storage)) {
+		/* drop the extra trailing hierarchy separator */
+		name = t_strndup(name, strlen(name)-1);
+	}
+
 	if (mail_storage_mailbox_delete(storage, name) < 0)
 		client_send_storage_error(cmd, storage);
 	else
--- a/src/imap/cmd-subscribe.c	Fri Jul 22 15:42:57 2005 +0300
+++ b/src/imap/cmd-subscribe.c	Fri Jul 22 17:20:44 2005 +0300
@@ -12,6 +12,18 @@
 	if (!client_read_string_args(cmd, 1, &mailbox))
 		return FALSE;
 
+	if ((client_workarounds & WORKAROUND_TB_EXTRA_MAILBOX_SEP) != 0) {
+		storage = client_find_storage(cmd, &mailbox);
+		if (storage == NULL)
+			return TRUE;
+
+		if (*mailbox != '\0' && mailbox[strlen(mailbox)-1] ==
+		    mail_storage_get_hierarchy_sep(storage)) {
+			/* drop the extra trailing hierarchy separator */
+			mailbox = t_strndup(mailbox, strlen(mailbox)-1);
+		}
+	}
+
 	if (!client_verify_mailbox_name(cmd, mailbox, subscribe, FALSE))
 		return TRUE;
 
--- a/src/imap/common.h	Fri Jul 22 15:42:57 2005 +0300
+++ b/src/imap/common.h	Fri Jul 22 17:20:44 2005 +0300
@@ -26,7 +26,8 @@
 enum client_workarounds {
 	WORKAROUND_DELAY_NEWMAIL		= 0x01,
 	WORKAROUND_OUTLOOK_IDLE			= 0x02,
-	WORKAROUND_NETSCAPE_EOH			= 0x04
+	WORKAROUND_NETSCAPE_EOH			= 0x04,
+	WORKAROUND_TB_EXTRA_MAILBOX_SEP		= 0x08
 };
 
 extern struct ioloop *ioloop;
--- a/src/imap/main.c	Fri Jul 22 15:42:57 2005 +0300
+++ b/src/imap/main.c	Fri Jul 22 17:20:44 2005 +0300
@@ -32,6 +32,7 @@
 	{ "delay-newmail", WORKAROUND_DELAY_NEWMAIL },
 	{ "outlook-idle", WORKAROUND_OUTLOOK_IDLE },
 	{ "netscape-eoh", WORKAROUND_NETSCAPE_EOH },
+	{ "tb-extra-mailbox-sep", WORKAROUND_TB_EXTRA_MAILBOX_SEP },
 	{ NULL, 0 }
 };