# HG changeset patch # User Timo Sirainen # Date 1255552498 14400 # Node ID f5ce7d271b569571ef232f7073bb7b30f191afb1 # Parent 7956cc1086e154de4d608856a05a8cb3f038e4f0 deliver: Escape local-part if it begins/ends with '.'. diff -r 7956cc1086e1 -r f5ce7d271b56 src/deliver/deliver.c --- a/src/deliver/deliver.c Wed Oct 14 13:24:47 2009 -0400 +++ b/src/deliver/deliver.c Wed Oct 14 16:34:58 2009 -0400 @@ -579,13 +579,15 @@ { 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; }