diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-10-18 14:19:03 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-10-18 14:19:03 +0900 |
commit | 01ae81e028f35fedac97e6e44336305786c3f14c (patch) | |
tree | 969b5801fb77af392ed32c38739001954446d3bb /mailinfo.c | |
parent | b8a4e894d42dd3b1c5dfa90e68ffaee5ab27dcc2 (diff) | |
parent | c8cf423eab6f260128859dfec991c36c54a3551c (diff) | |
download | git-01ae81e028f35fedac97e6e44336305786c3f14c.tar.gz git-01ae81e028f35fedac97e6e44336305786c3f14c.tar.xz |
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
Diffstat (limited to 'mailinfo.c')
-rw-r--r-- | mailinfo.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/mailinfo.c b/mailinfo.c index bd574cb75..70187e3eb 100644 --- a/mailinfo.c +++ b/mailinfo.c @@ -368,11 +368,16 @@ static struct strbuf *decode_q_segment(const struct strbuf *q_seg, int rfc2047) while ((c = *in++) != 0) { if (c == '=') { - int d = *in++; + int ch, d = *in; if (d == '\n' || !d) break; /* drop trailing newline */ - strbuf_addch(out, (hexval(d) << 4) | hexval(*in++)); - continue; + ch = hex2chr(in); + if (ch >= 0) { + strbuf_addch(out, ch); + in += 2; + continue; + } + /* garbage -- fall through */ } if (rfc2047 && c == '_') /* rfc2047 4.2 (2) */ c = 0x20; |