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.
int last)
{
char *d, *s;
- char c;
+ char c = 0;
- int kind;
+ int kind = -1;
int soft = 0;
/* decode the line */
}
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;