Skip to content

Commit

Permalink
lib-lda: Parse Return-Path header using RFC5322 (IMF) "path" syntax, …
Browse files Browse the repository at this point in the history
…rather than RFC5321 (SMTP) "Path" syntax.

SMTP does not allow white space, which causes all kinds of trouble when the
address is parsed from a header field.
  • Loading branch information
stephanbosch authored and villesavolainen committed Mar 13, 2018
1 parent 435e4ff commit 61f6497
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/lib-lda/mail-deliver.c
Expand Up @@ -405,8 +405,8 @@ int mail_deliver_save(struct mail_deliver_context *ctx, const char *mailbox,
const struct smtp_address *
mail_deliver_get_return_address(struct mail_deliver_context *ctx)
{
struct smtp_address *address;
const char *path, *error;
struct message_address *addr;
const char *path;
int ret;

if (!smtp_address_isnull(ctx->mail_from))
Expand All @@ -421,13 +421,14 @@ mail_deliver_get_return_address(struct mail_deliver_context *ctx)
}
return NULL;
}
if (smtp_address_parse_path(ctx->pool, path,
SMTP_ADDRESS_PARSE_FLAG_BRACKETS_OPTIONAL,
&address, &error) < 0) {
i_warning("Failed to parse return-path header: %s", error);
if (message_address_parse_path(pool_datastack_create(),
(const unsigned char *)path,
strlen(path), &addr) < 0) {
i_warning("Failed to parse return-path header");
return NULL;
}
return address;

return smtp_address_create_from_msg(ctx->pool, addr);
}

const char *mail_deliver_get_new_message_id(struct mail_deliver_context *ctx)
Expand Down

0 comments on commit 61f6497

Please sign in to comment.