Mercurial > dovecot > core-2.2
changeset 10057:21a09d9105b2 HEAD
lmtp: Drop quotes around local-part in RCPT TO command if possible.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 14 Oct 2009 15:45:52 -0400 |
parents | 4996ca56a1ee |
children | b81f4a4076de |
files | src/lmtp/commands.c |
diffstat | 1 files changed, 35 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lmtp/commands.c Wed Oct 14 13:25:33 2009 -0400 +++ b/src/lmtp/commands.c Wed Oct 14 15:45:52 2009 -0400 @@ -4,6 +4,7 @@ #include "ioloop.h" #include "array.h" #include "str.h" +#include "strescape.h" #include "istream.h" #include "ostream.h" #include "istream-dot.h" @@ -227,6 +228,39 @@ return TRUE; } +static const char *lmtp_unescape_address(const char *name) +{ + string_t *str; + const char *p; + + if (*name != '"') + return name; + + /* quoted-string local-part. drop the quotes unless there's a + '@' character inside or there's an error. */ + str = t_str_new(128); + for (p = name+1; *p != '"'; p++) { + if (*p == '\0') + return name; + if (*p == '\\') { + if (p[1] == '\0') { + /* error */ + return name; + } + p++; + } + if (*p == '@') + return name; + str_append_c(str, *p); + } + p++; + if (*p != '@' && *p != '\0') + return name; + + str_append(str, p); + return str_c(str); +} + int cmd_rcpt(struct client *client, const char *args) { struct mail_recipient rcpt; @@ -254,7 +288,7 @@ } memset(&rcpt, 0, sizeof(rcpt)); - name = t_strndup(addr + 4, len - 5); + name = lmtp_unescape_address(t_strndup(addr + 4, len - 5)); if (rcpt_is_duplicate(client, name)) { client_send_line(client, "250 2.1.5 OK, ignoring duplicate");