changeset 9430:f5ce7d271b56 HEAD

deliver: Escape local-part if it begins/ends with '.'.
author Timo Sirainen <tss@iki.fi>
date Wed, 14 Oct 2009 16:34:58 -0400
parents 7956cc1086e1
children a8254e6d5ada
files src/deliver/deliver.c
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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;
 }