summaryrefslogtreecommitdiff
path: root/mailinfo.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-09-28 05:47:55 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-09-28 05:47:56 (GMT)
commit2812ca7f0e11f6a46c8b1b5b4450df20412c22be (patch)
treebb22ffaa65928620c3f55ddfbc4082f4ea3e2f3d /mailinfo.c
parent1ba75ffd0194b965a1fa510f5f4571333544eaf9 (diff)
parentc8cf423eab6f260128859dfec991c36c54a3551c (diff)
downloadgit-2812ca7f0e11f6a46c8b1b5b4450df20412c22be.zip
git-2812ca7f0e11f6a46c8b1b5b4450df20412c22be.tar.gz
git-2812ca7f0e11f6a46c8b1b5b4450df20412c22be.tar.bz2
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
Diffstat (limited to 'mailinfo.c')
-rw-r--r--mailinfo.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/mailinfo.c b/mailinfo.c
index bcdbf98..a89db22 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -367,11 +367,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;