summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d598075)
raw | patch | inline | side by side (parent: d598075)
author | Junio C Hamano <junkio@cox.net> | |
Fri, 21 Apr 2006 07:06:58 +0000 (00:06 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 21 Apr 2006 07:09:28 +0000 (00:09 -0700) |
Quoted-Printable (RFC 2045) and the "Q" encoding (RFC 2047) are
subtly different; the latter is used on the mail header and an
underscore needs to be decoded to 0x20.
Signed-off-by: Junio C Hamano <junkio@cox.net>
subtly different; the latter is used on the mail header and an
underscore needs to be decoded to 0x20.
Signed-off-by: Junio C Hamano <junkio@cox.net>
mailinfo.c | patch | blob | history |
diff --git a/mailinfo.c b/mailinfo.c
index 3c56f8c10801bdc93eaaac6319e477f81c096717..b27651935db85cf0ab651d523c502943d137b7cd 100644 (file)
--- a/mailinfo.c
+++ b/mailinfo.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)) {
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;
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)
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);