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: mutt-1-5-20-rel~50 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5dc1ce66becc277af53065998977ce99a29d4a90;p=mutt 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 e9cfafb4..f0fe9667 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;