Skip to content

Commit 01ae81e

Browse files
committed
Merge branch 'rs/mailinfo-qp-decode-fix' into maint
"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 b8a4e89 + c8cf423 commit 01ae81e

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

mailinfo.c

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

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

0 commit comments

Comments
 (0)