summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2017-09-21 14:53:13 +0200
committerLeah Neukirchen <leah@vuxu.org>2017-09-21 14:53:13 +0200
commitd4cbac0aa5a58e0ea9e8522300bdc24b4d98980f (patch)
tree86e3bca805d03512bfb8cc3c9be3dcfee2be149c
parent54435b30b6c9f42d13842927e20c27aa267ef960 (diff)
downloadmblaze-d4cbac0aa5a58e0ea9e8522300bdc24b4d98980f.tar.gz
mblaze-d4cbac0aa5a58e0ea9e8522300bdc24b4d98980f.tar.xz
mblaze-d4cbac0aa5a58e0ea9e8522300bdc24b4d98980f.zip
mmime: gen_qp: quote ^From and ^.$ to be safe
-rw-r--r--mmime.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/mmime.c b/mmime.c
index 83e0d82..e8426d1 100644
--- a/mmime.c
+++ b/mmime.c
@@ -85,7 +85,11 @@ int gen_qp(uint8_t *s, off_t size, int maxlinelen, int linelen)
 		}
 
 		if ((s[i] > 126) ||
-		    (s[i] == '=')) {
+		    (s[i] == '=') ||
+		    (linelen == 0 &&
+		     (strncmp((char *)s, "From ", 5) == 0 ||
+	             (s[i] == '.' && i+1 < size &&
+		      (s[i+1] == '\n' || s[i+1] == '\r'))))) {
 			printf("=%02X", s[i]);
 			linelen += 3;
 			prev = s[i];