From 176943b9658b1fa9ae3972156100d831d19c3576 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 17 Sep 2012 14:17:58 -0700 Subject: mailinfo: do not concatenate charset= attribute values from mime headers "Content-type: text/plain; charset=UTF-8" header should not appear twice in the input, but it is always better to gracefully deal with such a case. The current code concatenates the value to the values we have seen previously, producing nonsense such as "utf8UTF-8". Instead of concatenating, forget the previous value and use the last value we see. Signed-off-by: Junio C Hamano --- builtin/mailinfo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'builtin') diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index eaf9e157a..dd8b67cfa 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -160,10 +160,9 @@ static int slurp_attr(const char *line, const char *name, struct strbuf *attr) 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++; -- cgit v1.2.1