From d4cbac0aa5a58e0ea9e8522300bdc24b4d98980f Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Thu, 21 Sep 2017 14:53:13 +0200 Subject: [PATCH] mmime: gen_qp: quote ^From and ^.$ to be safe --- mmime.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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];