changeset 22405:fbc5f327ae91

lmtp: Use message_detail_address_parse
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Mon, 03 Jul 2017 18:27:53 +0300
parents 47b1528ad6f3
children 8b81cd47ede8
files src/lmtp/commands.c
diffstat 1 files changed, 3 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/lmtp/commands.c	Mon Jul 03 19:00:14 2017 +0300
+++ b/src/lmtp/commands.c	Mon Jul 03 18:27:53 2017 +0300
@@ -30,6 +30,7 @@
 #include "mail-autoexpunge.h"
 #include "mail-namespace.h"
 #include "mail-deliver.h"
+#include "message-address.h"
 #include "main.h"
 #include "client.h"
 #include "commands.h"
@@ -462,31 +463,6 @@
 	return str_c(str);
 }
 
-static void rcpt_address_parse(struct client *client, const char *address,
-			       const char **username_r, const char **detail_r)
-{
-	const char *p, *domain;
-
-	*username_r = address;
-	*detail_r = "";
-
-	if (*client->unexpanded_lda_set->recipient_delimiter == '\0')
-		return;
-
-	domain = strchr(address, '@');
-	p = strstr(address, client->unexpanded_lda_set->recipient_delimiter);
-	if (p != NULL && (domain == NULL || p < domain)) {
-		/* user+detail@domain */
-		*username_r = t_strdup_until(*username_r, p);
-		if (domain == NULL)
-			*detail_r = p+1;
-		else {
-			*detail_r = t_strdup_until(p+1, domain);
-			*username_r = t_strconcat(*username_r, domain, NULL);
-		}
-	}
-}
-
 static void lmtp_address_translate(struct client *client, const char **address)
 {
 	const char *transpos = client->lmtp_set->lmtp_address_translate;
@@ -683,7 +659,8 @@
 			return 0;
 		}
 	}
-	rcpt_address_parse(client, address, &username, &detail);
+	message_detail_address_parse(client->unexpanded_lda_set->recipient_delimiter,
+				     address, &username, &detail);
 
 	client_state_set(client, "RCPT TO", address);