From: Timo Sirainen Date: Wed, 14 Oct 2009 20:35:16 +0000 (-0400) Subject: lda: Escape local-part if it begins/ends with '.'. X-Git-Tag: 2.0.alpha2~105 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3e29bd3f51a6d5156be54545e3cd446620824b6d;p=thirdparty%2Fdovecot%2Fcore.git lda: Escape local-part if it begins/ends with '.'. --HG-- branch : HEAD --- diff --git a/src/lda/main.c b/src/lda/main.c index 1bc1d12e97..b840bd8cd6 100644 --- a/src/lda/main.c +++ b/src/lda/main.c @@ -49,13 +49,15 @@ static const char *escape_local_part(const char *local_part) { const char *p; - /* if local_part isn't dot-atom-text, we need to return quoted-string */ + /* if local_part isn't dot-atom-text, we need to return quoted-string + dot-atom-text = 1*atext *("." 1*atext) */ for (p = local_part; *p != '\0'; p++) { - if (!IS_ATEXT(*p) && *p != '.') { - return t_strdup_printf("\"%s\"", - str_escape(local_part)); - } + if (!IS_ATEXT(*p) && *p != '.') + break; } + if (*p != '\0' || *local_part == '.' || + (p != local_part && p[-1] == '.')) + local_part = t_strdup_printf("\"%s\"", str_escape(local_part)); return local_part; }