dovecot-1.2: deliver: Escape local-part if it begins/ends with '.'.

dovecot at dovecot.org dovecot at dovecot.org
Wed Oct 14 23:35:06 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/f5ce7d271b56
changeset: 9430:f5ce7d271b56
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Oct 14 16:34:58 2009 -0400
description:
deliver: Escape local-part if it begins/ends with '.'.

diffstat:

1 file changed, 8 insertions(+), 6 deletions(-)
src/deliver/deliver.c |   14 ++++++++------

diffs (25 lines):

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 @@ static const char *escape_local_part(con
 {
 	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;
 }
 


More information about the dovecot-cvs mailing list