]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lda: Escape local-part if it begins/ends with '.'.
authorTimo Sirainen <tss@iki.fi>
Wed, 14 Oct 2009 20:35:16 +0000 (16:35 -0400)
committerTimo Sirainen <tss@iki.fi>
Wed, 14 Oct 2009 20:35:16 +0000 (16:35 -0400)
--HG--
branch : HEAD

src/lda/main.c

index 1bc1d12e975cec9551019760a0ccbae13311f89b..b840bd8cd6e4f2f939c1f7f4d50c05c8ef166d06 100644 (file)
@@ -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;
 }