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.)
This commit is contained in:
Leah Neukirchen 2017-07-09 21:25:55 +02:00
parent 958ad4e9f6
commit 4a685de739

11
mmime.c
View File

@ -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)