dovecot-2.0: lmtp: Drop quotes around local-part in RCPT TO comm...
dovecot at dovecot.org
dovecot at dovecot.org
Wed Oct 14 22:45:59 EEST 2009
details: http://hg.dovecot.org/dovecot-2.0/rev/21a09d9105b2
changeset: 10057:21a09d9105b2
user: Timo Sirainen <tss at iki.fi>
date: Wed Oct 14 15:45:52 2009 -0400
description:
lmtp: Drop quotes around local-part in RCPT TO command if possible.
diffstat:
1 file changed, 35 insertions(+), 1 deletion(-)
src/lmtp/commands.c | 36 +++++++++++++++++++++++++++++++++++-
diffs (60 lines):
diff -r 4996ca56a1ee -r 21a09d9105b2 src/lmtp/commands.c
--- 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 @@ static bool client_proxy_rcpt(struct cli
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 @@ int cmd_rcpt(struct client *client, cons
}
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");
More information about the dovecot-cvs
mailing list