diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-01-31 18:09:17 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-01-31 18:09:17 -0800 |
commit | c0f6f67b3d6c8afb89847b6b7bc187d7bed260eb (patch) | |
tree | e264c1f959d9452b7404e6191f3fa7a2ce222859 /builtin-mailinfo.c | |
parent | 15b8e94aee06f004da178bc0bfaabd50a0fda242 (diff) | |
parent | c32815f903f50a44006f6d12da11492141e70d73 (diff) | |
download | git-c0f6f67b3d6c8afb89847b6b7bc187d7bed260eb.tar.gz |
Merge branch 'ks/maint-mailinfo-folded'
* ks/maint-mailinfo-folded:
mailinfo: tests for RFC2047 examples
mailinfo: add explicit test for mails like '<a.u.thor@example.com> (A U Thor)'
mailinfo: 'From:' header should be unfold as well
mailinfo: correctly handle multiline 'Subject:' header
Diffstat (limited to 'builtin-mailinfo.c')
-rw-r--r-- | builtin-mailinfo.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index f7c8c08b32..d4dc23a363 100644 --- a/builtin-mailinfo.c +++ b/builtin-mailinfo.c @@ -430,13 +430,6 @@ static struct strbuf *decode_b_segment(const struct strbuf *b_seg) c -= 'a' - 26; else if ('0' <= c && c <= '9') c -= '0' - 52; - else if (c == '=') { - /* padding is almost like (c == 0), except we do - * not output NUL resulting only from it; - * for now we just trust the data. - */ - c = 0; - } else continue; /* garbage */ switch (pos++) { @@ -514,7 +507,25 @@ static int decode_header_bq(struct strbuf *it) rfc2047 = 1; if (in != ep) { - strbuf_add(&outbuf, in, ep - in); + /* + * We are about to process an encoded-word + * that begins at ep, but there is something + * before the encoded word. + */ + char *scan; + for (scan = in; scan < ep; scan++) + if (!isspace(*scan)) + break; + + if (scan != ep || in == it->buf) { + /* + * We should not lose that "something", + * unless we have just processed an + * encoded-word, and there is only LWS + * before the one we are about to process. + */ + strbuf_add(&outbuf, in, ep - in); + } in = ep; } /* E.g. @@ -860,6 +871,7 @@ static void handle_info(void) } output_header_lines(fout, "Subject", hdr); } else if (!memcmp(header[i], "From", 4)) { + cleanup_space(hdr); handle_from(hdr); fprintf(fout, "Author: %s\n", name.buf); fprintf(fout, "Email: %s\n", email.buf); |