]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
Fix another regression in RFC 5321
authorBaptiste Daroussin <bapt@FreeBSD.org>
Fri, 31 May 2024 13:42:07 +0000 (15:42 +0200)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Fri, 31 May 2024 13:42:07 +0000 (15:42 +0200)
src/mail-functions.c
tests/mlmmj-receive.in
tests/mlmmj.c

index d51dfa449b3c33ef8f317653134d1ca32896f495..2a4b7c19bb7c69c410ac0542eda0e3035667bf54 100644 (file)
@@ -91,9 +91,19 @@ write_mailbody(int sockfd, FILE *fp, const char *tohdr)
                next = fgetc(fp);
                dprintf(sockfd, "\r\n");
                if (next == '.') {
+                       /*
+                        * o Before sending a line of mail text, the SMTP client checks the
+                        * first character of the line. If it is a period, one additional
+                        * period is inserted at the beginning of the line.
+                        * 
+                        * o When a line of mail text is received by the SMTP server, it checks
+                        * the line. If the line is composed of a single period, it is
+                        * treated as the end of mail indicator. If the first character is a
+                        * period and there are other characters on the line, the first
+                        * character is deleted.
+                        */
                        c = fgetc(fp);
-                       if (c == EOF || c == '\n')
-                               dprintf(sockfd, ".");
+                       dprintf(sockfd, ".");
                        ungetc(c, fp);
                }
                if (addhdr && tohdr != NULL && next == '\n') {
index f3cb823aa5c59156adf026c54b29b7a7700cc148..2267d43d5c364974a07b73c4cc16307ca4567f14 100644 (file)
@@ -2924,7 +2924,7 @@ To: test@mlmmjtest
 Subject: yeah\r
 \r
 Hello\r
-.world\r
+..world\r
 \r
 .\r
 MAIL FROM:<test+bounces-1-user2=test@mlmmjtest>\r
@@ -2935,7 +2935,7 @@ To: test@mlmmjtest
 Subject: yeah\r
 \r
 Hello\r
-.world\r
+..world\r
 \r
 .\r
 QUIT\r
index 5d5ffdfb3736257ad16d3b4724edfd7eb5f499b9..c48cacf63f98d89288fc23ceeeafaefde315b297 100644 (file)
@@ -611,7 +611,7 @@ ATF_TC_BODY(write_mailbody, tc)
        }
 
        /* New line starting with a dot */
-       atf_utils_create_file("myemailbody.txt", "line\n.no");
+       atf_utils_create_file("myemailbody.txt", "line\n..no");
        fp = fopen("myemailbody.txt", "r");
        ATF_REQUIRE(fp != NULL);
        fd = open("out.txt", O_CREAT|O_TRUNC|O_WRONLY, 0644);