--- dovecot-1.0-test77.orig/src/imap/cmd-list.c	Sun Apr 17 17:37:05 2005
+++ dovecot-1.0-test77/src/imap/cmd-list.c	Wed Jul 13 16:10:27 2005
@@ -372,7 +372,8 @@
 		   concept which probably no other client uses than Pine.
 		   Just try our best to emulate UW-IMAP behavior and hopefully
 		   we're fine. */
-		ns = namespace_find(client->namespaces, &ref);
+		const char *ref_copy = t_strdup(ref);
+		ns = namespace_find(client->namespaces, &ref_copy);
 		if (ns == NULL) {
 			const char *empty = "";
 			ns = namespace_find(client->namespaces, &empty);
@@ -405,6 +406,28 @@
 		}
 		client_send_tagline(cmd, "OK List completed.");
 	} else {
+
+		if (*ref == '\0' && !lsub) {
+			/* LIST "" "something" */
+			const char *mask_copy = t_strdup(mask);
+			ns = namespace_find(client->namespaces, &mask_copy);
+			if (ns == NULL) {
+				const char *empty = "";
+				ns = namespace_find(client->namespaces, &empty);
+			}
+			if (*ns->prefix != '\0' && *mask_copy == '\0') {
+				/* namespace, return it */
+				string_t *str = t_str_new(64);
+				str_printfa(str, "* LIST (\\Noselect) \"%s\" ",
+				    ns->sep_str);
+				imap_quote_append_string(str, ns->prefix,
+							 FALSE);
+				client_send_line(client, str_c(str));
+				client_send_tagline(client, "OK List completed.");
+				return TRUE;
+			}
+		}
+
 		ctx = p_new(cmd->pool, struct cmd_list_context, 1);
 		ctx->ref = ref;
 		ctx->mask = mask;
