From: Baptiste Daroussin Date: Fri, 31 May 2024 13:42:07 +0000 (+0200) Subject: Fix another regression in RFC 5321 X-Git-Tag: RELEASE_1_4_6~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a942b75f7fd7e37e355eab9dfc944c0386954a9c;p=thirdparty%2Fmlmmj.git Fix another regression in RFC 5321 --- diff --git a/src/mail-functions.c b/src/mail-functions.c index d51dfa44..2a4b7c19 100644 --- a/src/mail-functions.c +++ b/src/mail-functions.c @@ -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') { diff --git a/tests/mlmmj-receive.in b/tests/mlmmj-receive.in index f3cb823a..2267d43d 100644 --- a/tests/mlmmj-receive.in +++ b/tests/mlmmj-receive.in @@ -2924,7 +2924,7 @@ To: test@mlmmjtest Subject: yeah Hello -.world +..world . MAIL FROM: @@ -2935,7 +2935,7 @@ To: test@mlmmjtest Subject: yeah Hello -.world +..world . QUIT diff --git a/tests/mlmmj.c b/tests/mlmmj.c index 5d5ffdfb..c48cacf6 100644 --- a/tests/mlmmj.c +++ b/tests/mlmmj.c @@ -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);