changeset 413:7c5e51c53f72

Finally found the newline that was to much in spool_read_header().
author markus schnalke <meillo@marmaro.de>
date Wed, 29 Feb 2012 14:22:44 +0100
parents 8a62bebda631
children 309935f59820
files src/parse.c
diffstat 1 files changed, 17 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/parse.c	Wed Feb 29 13:33:40 2012 +0100
+++ b/src/parse.c	Wed Feb 29 14:22:44 2012 +0100
@@ -390,6 +390,12 @@
 	gchar *addr_end;
 	gboolean ret;
 
+	if (!string) {
+		return NULL;
+	}
+	while (isspace(*string)) {
+		string++;
+	}
 	/* TODO: what about (string == NULL)? */
 	if (string && (string[0] == '\0')) {
 		address *addr = g_malloc(sizeof(address));
@@ -411,21 +417,20 @@
 	if (!ret) {
 		return NULL;
 	}
-
-	address *addr = g_malloc(sizeof(address));
-	gchar *p = addr_end;
-
-	memset(addr, 0, sizeof(address));
-
-	if (loc_beg[0] == '|') {
+	if (*loc_beg == '|') {
 		parse_error = g_strdup("no pipe allowed for RFC 822/821 address");
 		return NULL;
 	}
 
+	address *addr = g_malloc(sizeof(address));
+	memset(addr, 0, sizeof(address));
+
+	gchar *p = addr_end;
 	while (*p && (*p != ',')) {
+		/* it seems as if we do this for the code in rewrite.c */
 		p++;
 	}
-	addr->address = g_strndup(string, p - string);
+	addr->address = g_strstrip(g_strndup(string, p - string));
 	addr->local_part = g_strndup(loc_beg, loc_end - loc_beg);
 
 #ifdef PARSE_TEST
@@ -448,6 +453,10 @@
 		*end = p;
 	}
 
+	DEBUG(6) debugf("_create_address(): address: `%s'\n", addr->address);
+	DEBUG(6) debugf("_create_address(): local_part: `%s'\n", addr->local_part);
+	DEBUG(6) debugf("_create_address(): domain: `%s'\n", addr->domain);
+
 #ifndef PARSE_TEST
 	addr_unmark_delivered(addr);
 #endif