[dovecot-cvs] dovecot/src/imap cmd-list.c,1.22,1.23 cmd-status.c,1.10,1.11

cras at procontrol.fi cras at procontrol.fi
Wed Apr 2 06:05:40 EEST 2003


Update of /home/cvs/dovecot/src/imap
In directory danu:/tmp/cvs-serv7538/imap

Modified Files:
	cmd-list.c cmd-status.c 
Log Message:
Mailbox names are now sent through imap-quoter instead of just escaping it.
This means that mailbox names that would require escapes are instead sent
as literals now.



Index: cmd-list.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-list.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmd-list.c	20 Mar 2003 17:38:39 -0000	1.22
+++ cmd-list.c	2 Apr 2003 02:05:38 -0000	1.23
@@ -1,7 +1,9 @@
 /* Copyright (C) 2002 Timo Sirainen */
 
 #include "common.h"
+#include "str.h"
 #include "strescape.h"
+#include "imap-quote.h"
 #include "imap-match.h"
 #include "commands.h"
 
@@ -23,6 +25,7 @@
 	struct client *client;
 	const char *response_name;
 	const char *sep;
+	char sep_chr;
 	struct imap_match_glob *glob;
 	int listext, no_placeholder;
 };
@@ -72,9 +75,7 @@
 
 		t_push();
 
-		/* escaping is done here to make sure we don't try to escape
-		   the separator char */
-		name = str_escape(t_strdup_until(name, path));
+		name = t_strdup_until(name, path);
 
 		/* find the node */
 		while (*node != NULL) {
@@ -116,16 +117,18 @@
 static void list_send(struct list_send_context *ctx, struct list_node *node,
 		      const char *path)
 {
-	const char *name, *send_name, *str, *flagstr;
+	const char *name, *send_name, *flagstr;
 	enum imap_match_result match;
+	string_t *str;
 
 	for (; node != NULL; node = node->next) {
 		t_push();
 
 		/* Send INBOX always uppercased */
-		if (path != NULL)
-			name = t_strconcat(path, ctx->sep, node->name, NULL);
-		else if (strcasecmp(node->name, "INBOX") == 0)
+		if (path != NULL) {
+			name = t_strdup_printf("%s%c%s", path, ctx->sep_chr,
+					       node->name);
+		} else if (strcasecmp(node->name, "INBOX") == 0)
 			name = "INBOX";
 		else
 			name = node->name;
@@ -147,8 +150,9 @@
 			      this is sent
 			   c) cyrus and courier doesn't do this either..
 
-			   if (match == IMAP_MATCH_CHILDREN) {
-				send_name = t_strconcat(name, ctx->sep, NULL);
+			if (match == IMAP_MATCH_CHILDREN) {
+				send_name = t_strdup_printf("%s%c", name,
+							    ctx->sep);
 				buf = str_unescape(t_strdup_noconst(send_name));
 				match = imap_match(ctx->glob, buf);
 			}*/
@@ -158,10 +162,13 @@
 			/* node->name should already be escaped */
 			flagstr = mailbox_flags2str(node->flags, ctx->listext,
 						    ctx->no_placeholder);
-			str = t_strdup_printf("* %s (%s) \"%s\" \"%s\"",
-					      ctx->response_name, flagstr,
-					      ctx->sep, send_name);
-			client_send_line(ctx->client, str);
+			t_push();
+			str = t_str_new(256);
+			str_printfa(str, "* %s (%s) \"%s\" ",
+				    ctx->response_name, flagstr, ctx->sep);
+			imap_quote_append_string(str, send_name);
+			client_send_line(ctx->client, str_c(str));
+			t_pop();
 		}
 
 		if (node->children != NULL)
@@ -173,8 +180,8 @@
 
 static void list_and_sort(struct client *client,
 			  struct mailbox_list_context *ctx,
-			  const char *response_name,
-			  const char *sep, const char *mask,
+			  const char *response_name, const char *mask,
+			  const char *sep, char sep_chr,
 			  enum mailbox_list_flags list_flags, int listext)
 {
 	struct mailbox_list *list;
@@ -194,6 +201,7 @@
 	send_ctx.client = client;
 	send_ctx.response_name = response_name;
 	send_ctx.sep = sep;
+	send_ctx.sep_chr = sep_chr;
 	send_ctx.glob = imap_match_init(data_stack_pool, mask, TRUE,
 					client->storage->hierarchy_sep);
 	send_ctx.listext = listext;
@@ -209,19 +217,19 @@
 			  const char *reply, const char *sep, int listext)
 {
 	struct mailbox_list *list;
-	const char *name, *str;
+	string_t *str;
 
 	while ((list = client->storage->list_mailbox_next(ctx)) != NULL) {
 		t_push();
+		str = t_str_new(256);
+		str_printfa(str, "* %s (%s) \"%s\" ", reply,
+			    mailbox_flags2str(list->flags, listext, FALSE),
+			    sep);
 		if (strcasecmp(list->name, "INBOX") == 0)
-			name = "INBOX";
+			str_append(str, "INBOX");
 		else
-			name = str_escape(list->name);
-		str = t_strdup_printf("* %s (%s) \"%s\" \"%s\"", reply,
-				      mailbox_flags2str(list->flags, listext,
-							FALSE),
-				      sep, name);
-		client_send_line(client, str);
+			imap_quote_append_string(str, list->name);
+		client_send_line(client, str_c(str));
 		t_pop();
 	}
 }
@@ -333,8 +341,9 @@
 				list_unsorted(client, ctx, response_name, sep,
 					      listext);
 			} else {
-				list_and_sort(client, ctx, response_name, sep,
-					      mask, list_flags, listext);
+				list_and_sort(client, ctx, response_name, mask,
+					      sep, sep_chr, list_flags,
+					      listext);
 			}
 
 			failed = !client->storage->list_mailbox_deinit(ctx);

Index: cmd-status.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-status.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- cmd-status.c	3 Feb 2003 05:11:16 -0000	1.10
+++ cmd-status.c	2 Apr 2003 02:05:38 -0000	1.11
@@ -2,7 +2,7 @@
 
 #include "common.h"
 #include "str.h"
-#include "strescape.h"
+#include "imap-quote.h"
 #include "commands.h"
 
 /* Returns status items, or -1 if error */
@@ -110,7 +110,10 @@
 	}
 
 	str = t_str_new(128);
-	str_printfa(str, "* STATUS \"%s\" (", str_escape(mailbox));
+	str_append(str, "* STATUS ");
+        imap_quote_append_string(str, mailbox);
+	str_append(str, " (");
+
 	if (items & STATUS_MESSAGES)
 		str_printfa(str, "MESSAGES %u ", status.messages);
 	if (items & STATUS_RECENT)




More information about the dovecot-cvs mailing list