Hey everyone, as my previous emails apparently got stuck in a spam filter I'll try this again. The patches attached here allow for more than one recipient delimiter in the address. Which is allowed in postfix since version 2.11. E.g. lhw+post...@ring0.de would be equal to lhw-post...@ring0.de if configured that way. Same as postfix only the first discovered delimiter is taken into account and the priority is first to last in the list.
Lennart
diff -r d7defdcfe039 src/lmtp/commands.c --- a/src/lmtp/commands.c Thu Feb 05 19:40:25 2015 +0200 +++ b/src/lmtp/commands.c Fri Feb 06 01:23:51 2015 +0100 @@ -281,11 +281,11 @@ } static const char * -address_add_detail(struct client *client, const char *username, +address_add_detail(const char *username, const char delim_c, const char *detail) { - const char *delim = client->unexpanded_lda_set->recipient_delimiter; const char *domain; + const char delim[] = {delim_c, '\0'}; domain = strchr(username, '@'); if (domain == NULL) @@ -297,7 +297,7 @@ } static bool client_proxy_rcpt(struct client *client, const char *address, - const char *username, const char *detail, + const char *username, const char delim, const char *detail, const struct lmtp_recipient_params *params) { struct auth_master_connection *auth_conn; @@ -352,7 +352,7 @@ if (*detail == '\0') address = username; else - address = address_add_detail(client, username, detail); + address = address_add_detail(username, delim, detail); } else if (client_proxy_is_ourself(client, &set)) { i_error("Proxying to <%s> loops to itself", username); client_send_line(client, "554 5.4.6 <%s> " @@ -440,9 +440,11 @@ } static void rcpt_address_parse(struct client *client, const char *address, - const char **username_r, const char **detail_r) + const char **username_r, char *delim_r, + const char **detail_r) { const char *p, *domain; + size_t idx; *username_r = address; *detail_r = ""; @@ -451,8 +453,12 @@ return; domain = strchr(address, '@'); - p = strstr(address, client->unexpanded_lda_set->recipient_delimiter); + /* first character that matches the recipient_delimiter */ + idx = strcspn(address, client->unexpanded_lda_set->recipient_delimiter); + p = address[idx] != '\0' ? address + idx : NULL; + if (p != NULL && (domain == NULL || p < domain)) { + *delim_r = *p; /* user+detail@domain */ *username_r = t_strdup_until(*username_r, p); if (domain == NULL) @@ -570,6 +576,7 @@ const char *params, *address, *username, *detail, *prefix; const char *const *argv; const char *error = NULL; + char delim = '\0'; int ret = 0; if (client->state.mail_from == NULL) { @@ -595,13 +602,13 @@ return 0; } } - rcpt_address_parse(client, address, &username, &detail); + rcpt_address_parse(client, address, &username, &delim, &detail); client_state_set(client, "RCPT TO", address); if (client->lmtp_set->lmtp_proxy) { - if (client_proxy_rcpt(client, address, username, detail, - &rcpt.params)) + if (client_proxy_rcpt(client, address, username, delim, + detail, &rcpt.params)) return 0; }
diff -r cd8194a2469e src/lib-sieve/plugins/subaddress/ext-subaddress.c --- a/src/lib-sieve/plugins/subaddress/ext-subaddress.c Fri Jan 16 18:25:51 2015 +0100 +++ b/src/lib-sieve/plugins/subaddress/ext-subaddress.c Fri Jan 30 12:37:34 2015 +0100 @@ -142,8 +142,10 @@ struct ext_subaddress_config *config = (struct ext_subaddress_config *) addrp->object.ext->context; const char *delim; + size_t idx; - delim = strstr(address->local_part, config->delimiter); + idx = strcspn(address->local_part, config->delimiter); + delim = address->local_part[idx] != '\0' ? address->local_part + idx : NULL; if ( delim == NULL ) return address->local_part;