From: Junio C Hamano Date: Tue, 25 Sep 2012 17:39:56 +0000 (-0700) Subject: Merge branch 'jc/maint-mailinfo-mime-attr' X-Git-Tag: v1.8.0-rc0~25 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b1bb02dede05e26ae39908ae4ad35f011583bd50?hp=-c Merge branch 'jc/maint-mailinfo-mime-attr' When "git am" is fed an input that has multiple "Content-type: ..." header, it did not grok charset= attribute correctly. * jc/maint-mailinfo-mime-attr: mailinfo: do not concatenate charset= attribute values from mime headers --- b1bb02dede05e26ae39908ae4ad35f011583bd50 diff --combined builtin/mailinfo.c index b691b77158,dd8b67cfaa..2b3f4d955e --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@@ -160,10 -160,9 +160,9 @@@ static int slurp_attr(const char *line const char *ends, *ap = strcasestr(line, name); size_t sz; - if (!ap) { - strbuf_setlen(attr, 0); + strbuf_setlen(attr, 0); + if (!ap) return 0; - } ap += strlen(name); if (*ap == '"') { ap++; @@@ -232,9 -231,7 +231,9 @@@ static void cleanup_subject(struct strb case 'r': case 'R': if (subject->len <= at + 3) break; - if (!memcmp(subject->buf + at + 1, "e:", 2)) { + if ((subject->buf[at + 1] == 'e' || + subject->buf[at + 1] == 'E') && + subject->buf[at + 2] == ':') { strbuf_remove(subject, at, 3); continue; } @@@ -483,12 -480,36 +482,12 @@@ static struct strbuf *decode_b_segment( return out; } -/* - * When there is no known charset, guess. - * - * Right now we assume that if the target is UTF-8 (the default), - * and it already looks like UTF-8 (which includes US-ASCII as its - * subset, of course) then that is what it is and there is nothing - * to do. - * - * Otherwise, we default to assuming it is Latin1 for historical - * reasons. - */ -static const char *guess_charset(const struct strbuf *line, const char *target_charset) -{ - if (is_encoding_utf8(target_charset)) { - if (is_utf8(line->buf)) - return NULL; - } - return "ISO8859-1"; -} - static void convert_to_utf8(struct strbuf *line, const char *charset) { char *out; - if (!charset || !*charset) { - charset = guess_charset(line, metainfo_charset); - if (!charset) - return; - } - + if (!charset || !*charset) + return; if (!strcasecmp(metainfo_charset, charset)) return; out = reencode_string(line->buf, metainfo_charset, charset); diff --combined t/t5100/sample.mbox index 34a09a0fc1,fcc0e0d202..8b2ae064c3 --- a/t/t5100/sample.mbox +++ b/t/t5100/sample.mbox @@@ -12,7 -12,7 +12,7 @@@ Subject: [PATCH] a commit Here is a patch from A U Thor. --- - foo | 2 +- + foo | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/foo b/foo @@@ -52,7 -52,7 +52,7 @@@ two truly blank and another full of spa Hope this helps. --- - foo | 2 +- + foo | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/foo b/foo @@@ -83,7 -83,7 +83,7 @@@ Message-Id: --- - Documentation/git-cvsimport-script.txt | 9 ++++++++- - git-cvsimport-script | 4 ++-- + Documentation/git-cvsimport-script.txt | 9 ++++++++- + git-cvsimport-script | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) 50452f9c0c2df1f04d83a26266ba704b13861632 @@@ -379,7 -379,7 +379,7 @@@ Subject: [PATCH] a commit Here is a patch from A U Thor. --- - foo | 2 +- + foo | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/foo b/foo @@@ -449,7 -449,7 +449,7 @@@ memcmp("Subject: ", header[i], 7) will Signed-off-by: Lukas Sandström Signed-off-by: Junio C Hamano --- - builtin-mailinfo.c | 2 +- + builtin-mailinfo.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c @@@ -482,7 -482,7 +482,7 @@@ Content-Transfer-Encoding: quoted-print Here comes a commit log message, and its second line is here. --- - builtin-mailinfo.c | 4 ++-- + builtin-mailinfo.c | 4 ++-- diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index 3e5fe51..aabfe5c 100644 @@@ -587,7 -587,7 +587,7 @@@ everything before it in the message bod Signed-off-by: Junio C Hamano --- - builtin-mailinfo.c | 37 ++++++++++++++++++++++++++++++++++++- + builtin-mailinfo.c | 37 ++++++++++++++++++++++++++++++++++++- 1 files changed, 36 insertions(+), 1 deletions(-) diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c @@@ -683,3 -683,19 +683,19 @@@ index e69de29..d95f3ad 10064 @@ -0,0 +1 @@ +content + From nobody Mon Sep 17 00:00:00 2001 + From: A U Thor + Subject: A E I O U + Date: Mon, 17 Sep 2012 14:23:44 -0700 + MIME-Version: 1.0 + Content-Type: text/plain; charset="iso-2022-jp" + Content-type: text/plain; charset="UTF-8" + + New content here + + diff --git a/foo b/foo + index e69de29..d95f3ad 100644 + --- a/foo + +++ b/foo + @@ -0,0 +1 @@ + +New content