X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=mailinfo.c;h=b27651935db85cf0ab651d523c502943d137b7cd;hb=f8ba655ee4131e5c73c28a4ea854b24ce4058e1e;hp=3c56f8c10801bdc93eaaac6319e477f81c096717;hpb=b4a081b428c607f98c5d0a0eec8d543dc1f2abcd;p=git.git diff --git a/mailinfo.c b/mailinfo.c index 3c56f8c1..b2765193 100644 --- a/mailinfo.c +++ b/mailinfo.c @@ -405,7 +405,7 @@ static unsigned hexval(int c) return ~0; } -static int decode_q_segment(char *in, char *ot, char *ep) +static int decode_q_segment(char *in, char *ot, char *ep, int rfc2047) { int c; while ((c = *in++) != 0 && (in <= ep)) { @@ -414,9 +414,11 @@ static int decode_q_segment(char *in, char *ot, char *ep) if (d == '\n' || !d) break; /* drop trailing newline */ *ot++ = ((hexval(d) << 4) | hexval(*in++)); + continue; } - else - *ot++ = c; + if (rfc2047 && c == '_') /* rfc2047 4.2 (2) */ + c = 0x20; + *ot++ = c; } *ot = 0; return 0; @@ -547,7 +549,7 @@ static void decode_header_bq(char *it) sz = decode_b_segment(cp + 3, piecebuf, ep); break; case 'q': - sz = decode_q_segment(cp + 3, piecebuf, ep); + sz = decode_q_segment(cp + 3, piecebuf, ep, 1); break; } if (sz < 0) @@ -569,7 +571,7 @@ static void decode_transfer_encoding(char *line) switch (transfer_encoding) { case TE_QP: ep = line + strlen(line); - decode_q_segment(line, line, ep); + decode_q_segment(line, line, ep, 0); break; case TE_BASE64: ep = line + strlen(line);