about summary refs log tree commit diff
path: root/mmime.c
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-07-09 21:25:55 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-07-09 21:25:55 +0200
commit4a685de739e09810a49bbcb7138a8e86d26bae82 (patch)
treeb1e0dfaa14c8be4eb959ea275facf6e26c5c6fbe /mmime.c
parent958ad4e9f634d71f5659b179c909449a6915fc51 (diff)
downloadmblaze-4a685de739e09810a49bbcb7138a8e86d26bae82.tar.gz
mblaze-4a685de739e09810a49bbcb7138a8e86d26bae82.tar.xz
mblaze-4a685de739e09810a49bbcb7138a8e86d26bae82.zip
mmime: ensure 7bit or 8bit Content-Transfer-Encoding for message/rfc822 parts
RFC 2046, Section 5.2.1:
> No encoding other than "7bit", "8bit", or "binary" is permitted for
> the body of a "message/rfc822" entity.

(We'll generate 8bit when we have to and put the blame on the MTA.)
Diffstat (limited to 'mmime.c')
-rw-r--r--mmime.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/mmime.c b/mmime.c
index bc6e3bc..34749e5 100644
--- a/mmime.c
+++ b/mmime.c
@@ -219,11 +219,16 @@ gen_file(char *file, char *ct)
 			bithigh++;
 	}
 
-	if (strcmp(ct, "message/rfc822") == 0 && maxlinelen < 997)
-		maxlinelen = 0;
-
 	gen_attachment(filename, cd);
 
+	if (strcmp(ct, "message/rfc822") == 0) {
+		printf("Content-Type: %s\n", ct);
+		printf("Content-Transfer-Encoding: %dbit\n\n",
+		    (bitlow > 0 || bithigh > 0) ? 8 : 7);
+		fwrite(content, 1, size, stdout);
+		return 0;
+	}
+
 	if (bitlow == 0 && bithigh == 0 &&
 	    maxlinelen <= 78 && content[size-1] == '\n') {
 		if (!ct)