From: Rocco Rutte Date: Sun, 31 May 2009 10:54:19 +0000 (+0200) Subject: Turn trailing \r\n to \n for qp-encoded messages. X-Git-Tag: neomutt-20160307~624 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9104e6a66c59d074911d16b9feb0b3ac94c036c9;p=neomutt Turn trailing \r\n to \n for qp-encoded messages. RFC2045 (sect. 6.7, (1) general 8bit representation) states that neither CR nor LF of the trailing CRLF may be qp-encoded. So we ignore trailing qp-encoded CRs. See #2898 though this is a partial fix only. --- diff --git a/handler.c b/handler.c index e9cfafb49..f0fe96679 100644 --- a/handler.c +++ b/handler.c @@ -173,9 +173,9 @@ static void qp_decode_line (char *dest, char *src, size_t *l, int last) { char *d, *s; - char c; + char c = 0; - int kind; + int kind = -1; int soft = 0; /* decode the line */ @@ -191,7 +191,15 @@ static void qp_decode_line (char *dest, char *src, size_t *l, } if (!soft && last == '\n') - *d++ = '\n'; + { + /* neither \r nor \n as part of line-terminating CRLF + * may be qp-encoded, so remove \r and \n-terminate; + * see RfC2045, sect. 6.7, (1): General 8bit representation */ + if (kind == 0 && c == '\r') + *(d-1) = '\n'; + else + *d++ = '\n'; + } *d = '\0'; *l = d - dest;