Skip to content

Commit 2812ca7

Browse files
committed
Merge branch 'rs/mailinfo-qp-decode-fix'
"git mailinfo" was loose in decoding quoted printable and produced garbage when the two letters after the equal sign are not hexadecimal. This has been fixed. * rs/mailinfo-qp-decode-fix: mailinfo: don't decode invalid =XY quoted-printable sequences
2 parents 1ba75ff + c8cf423 commit 2812ca7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

mailinfo.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,16 @@ static struct strbuf *decode_q_segment(const struct strbuf *q_seg, int rfc2047)
367367

368368
while ((c = *in++) != 0) {
369369
if (c == '=') {
370-
int d = *in++;
370+
int ch, d = *in;
371371
if (d == '\n' || !d)
372372
break; /* drop trailing newline */
373-
strbuf_addch(out, (hexval(d) << 4) | hexval(*in++));
374-
continue;
373+
ch = hex2chr(in);
374+
if (ch >= 0) {
375+
strbuf_addch(out, ch);
376+
in += 2;
377+
continue;
378+
}
379+
/* garbage -- fall through */
375380
}
376381
if (rfc2047 && c == '_') /* rfc2047 4.2 (2) */
377382
c = 0x20;

0 commit comments

Comments
 (0)