about summary refs log tree commit diff
path: root/mmime.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-08-01 14:26:37 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-08-01 14:26:37 +0200
commit0ce958a22c82d45b4b0ce77dbcac2fd6f6822965 (patch)
treedbbde244734e396f1254557955af78173a3b1f2c /mmime.c
parent2aaa3cecd8a21c975c5bea886c678775627e90e7 (diff)
downloadmblaze-0ce958a22c82d45b4b0ce77dbcac2fd6f6822965.tar.gz
mblaze-0ce958a22c82d45b4b0ce77dbcac2fd6f6822965.tar.xz
mblaze-0ce958a22c82d45b4b0ce77dbcac2fd6f6822965.zip
mmime: only qp after newline when actually needed
Diffstat (limited to 'mmime.c')
-rw-r--r--mmime.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/mmime.c b/mmime.c
index 5e25082..c46b0a5 100644
--- a/mmime.c
+++ b/mmime.c
@@ -245,13 +245,19 @@ print_header(char *line) {
 			}
 			if (s < e) {
 				if (linelen + (e-s)+13 > 78) {
-					printf("\n");
-					linelen = 0;
+					printf("\n ");
+					linelen = 1;
+				}
+				if (highbit || s[0] == ' ') {
+					printf("=?UTF-8?Q?");
+					linelen += 13;
+					linelen += gen_qp((uint8_t *)s, e-s, 999, 1);
+					printf("?=");
+				} else {
+					fwrite(s, 1, e-s, stdout);
+					linelen += e-s;
+					prevq = 0;
 				}
-				printf(" =?UTF-8?Q?");
-				linelen += 13;
-				linelen += gen_qp((uint8_t *)s, e-s, 999, 1);
-				printf("?=");
 			}
 			prevq = 1;
 		} else {