changeset 8494:57e704c361a7 HEAD

fts-solr: Don't break if mailbox name contains '&' characters.
author Timo Sirainen <tss@iki.fi>
date Sat, 29 Nov 2008 22:39:04 +0200
parents 149c6ccc3df4
children ffb37c392166
files src/plugins/fts-solr/solr-connection.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/fts-solr/solr-connection.c	Sat Nov 29 19:24:59 2008 +0200
+++ b/src/plugins/fts-solr/solr-connection.c	Sat Nov 29 22:39:04 2008 +0200
@@ -325,6 +325,7 @@
 static void solr_lookup_xml_data(void *context, const char *str, int len)
 {
 	struct solr_lookup_xml_context *ctx = context;
+	char *new_name;
 
 	switch (ctx->content_state) {
 	case SOLR_XML_CONTENT_STATE_NONE:
@@ -339,8 +340,12 @@
 		} T_END;
 		break;
 	case SOLR_XML_CONTENT_STATE_MAILBOX:
+		/* this may be called multiple times, for example if input
+		   contains '&' characters */
+		new_name = ctx->mailbox == NULL ? i_strndup(str, len) :
+			i_strconcat(ctx->mailbox, t_strndup(str, len), NULL);
 		i_free(ctx->mailbox);
-		ctx->mailbox = i_strndup(str, len);
+		ctx->mailbox = new_name;
 		break;
 	case SOLR_XML_CONTENT_STATE_UIDVALIDITY:
 		if (uint32_parse(str, len, &ctx->uidvalidity) < 0)