mailinfo: don't decode invalid =XY quoted-printable sequences
Decode =XY in quoted-printable segments only if X and Y are hexadecimal digits, otherwise just copy them. That's at least better than interpreting negative results from hexval() as a character. Reported-by: Jeff King <peff@peff.net> Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
0bfff8146f
commit
c8cf423eab
11
mailinfo.c
11
mailinfo.c
@ -367,11 +367,16 @@ static struct strbuf *decode_q_segment(const struct strbuf *q_seg, int rfc2047)
|
|||||||
|
|
||||||
while ((c = *in++) != 0) {
|
while ((c = *in++) != 0) {
|
||||||
if (c == '=') {
|
if (c == '=') {
|
||||||
int d = *in++;
|
int ch, d = *in;
|
||||||
if (d == '\n' || !d)
|
if (d == '\n' || !d)
|
||||||
break; /* drop trailing newline */
|
break; /* drop trailing newline */
|
||||||
strbuf_addch(out, (hexval(d) << 4) | hexval(*in++));
|
ch = hex2chr(in);
|
||||||
continue;
|
if (ch >= 0) {
|
||||||
|
strbuf_addch(out, ch);
|
||||||
|
in += 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* garbage -- fall through */
|
||||||
}
|
}
|
||||||
if (rfc2047 && c == '_') /* rfc2047 4.2 (2) */
|
if (rfc2047 && c == '_') /* rfc2047 4.2 (2) */
|
||||||
c = 0x20;
|
c = 0x20;
|
||||||
|
Reference in New Issue
Block a user