mailinfo: fold decode_header_bq() into decode_header()
In olden days we might have wanted to behave differently in decode_header() if the header line was encoded with RFC2047, but we apparently do not do so, hence this helper function can go, together with its return value. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
2a5ce7cf0d
commit
3a8fcdaf84
@ -525,19 +525,17 @@ static void convert_to_utf8(struct strbuf *line, const char *charset)
|
|||||||
strbuf_attach(line, out, strlen(out), strlen(out));
|
strbuf_attach(line, out, strlen(out), strlen(out));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_header_bq(struct strbuf *it)
|
static void decode_header(struct strbuf *it)
|
||||||
{
|
{
|
||||||
char *in, *ep, *cp;
|
char *in, *ep, *cp;
|
||||||
struct strbuf outbuf = STRBUF_INIT, *dec;
|
struct strbuf outbuf = STRBUF_INIT, *dec;
|
||||||
struct strbuf charset_q = STRBUF_INIT, piecebuf = STRBUF_INIT;
|
struct strbuf charset_q = STRBUF_INIT, piecebuf = STRBUF_INIT;
|
||||||
int rfc2047 = 0;
|
|
||||||
|
|
||||||
in = it->buf;
|
in = it->buf;
|
||||||
while (in - it->buf <= it->len && (ep = strstr(in, "=?")) != NULL) {
|
while (in - it->buf <= it->len && (ep = strstr(in, "=?")) != NULL) {
|
||||||
int encoding;
|
int encoding;
|
||||||
strbuf_reset(&charset_q);
|
strbuf_reset(&charset_q);
|
||||||
strbuf_reset(&piecebuf);
|
strbuf_reset(&piecebuf);
|
||||||
rfc2047 = 1;
|
|
||||||
|
|
||||||
if (in != ep) {
|
if (in != ep) {
|
||||||
/*
|
/*
|
||||||
@ -567,22 +565,22 @@ static int decode_header_bq(struct strbuf *it)
|
|||||||
ep += 2;
|
ep += 2;
|
||||||
|
|
||||||
if (ep - it->buf >= it->len || !(cp = strchr(ep, '?')))
|
if (ep - it->buf >= it->len || !(cp = strchr(ep, '?')))
|
||||||
goto decode_header_bq_out;
|
goto release_return;
|
||||||
|
|
||||||
if (cp + 3 - it->buf > it->len)
|
if (cp + 3 - it->buf > it->len)
|
||||||
goto decode_header_bq_out;
|
goto release_return;
|
||||||
strbuf_add(&charset_q, ep, cp - ep);
|
strbuf_add(&charset_q, ep, cp - ep);
|
||||||
|
|
||||||
encoding = cp[1];
|
encoding = cp[1];
|
||||||
if (!encoding || cp[2] != '?')
|
if (!encoding || cp[2] != '?')
|
||||||
goto decode_header_bq_out;
|
goto release_return;
|
||||||
ep = strstr(cp + 3, "?=");
|
ep = strstr(cp + 3, "?=");
|
||||||
if (!ep)
|
if (!ep)
|
||||||
goto decode_header_bq_out;
|
goto release_return;
|
||||||
strbuf_add(&piecebuf, cp + 3, ep - cp - 3);
|
strbuf_add(&piecebuf, cp + 3, ep - cp - 3);
|
||||||
switch (tolower(encoding)) {
|
switch (tolower(encoding)) {
|
||||||
default:
|
default:
|
||||||
goto decode_header_bq_out;
|
goto release_return;
|
||||||
case 'b':
|
case 'b':
|
||||||
dec = decode_b_segment(&piecebuf);
|
dec = decode_b_segment(&piecebuf);
|
||||||
break;
|
break;
|
||||||
@ -601,17 +599,10 @@ static int decode_header_bq(struct strbuf *it)
|
|||||||
strbuf_addstr(&outbuf, in);
|
strbuf_addstr(&outbuf, in);
|
||||||
strbuf_reset(it);
|
strbuf_reset(it);
|
||||||
strbuf_addbuf(it, &outbuf);
|
strbuf_addbuf(it, &outbuf);
|
||||||
decode_header_bq_out:
|
release_return:
|
||||||
strbuf_release(&outbuf);
|
strbuf_release(&outbuf);
|
||||||
strbuf_release(&charset_q);
|
strbuf_release(&charset_q);
|
||||||
strbuf_release(&piecebuf);
|
strbuf_release(&piecebuf);
|
||||||
return rfc2047;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void decode_header(struct strbuf *it)
|
|
||||||
{
|
|
||||||
if (decode_header_bq(it))
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void decode_transfer_encoding(struct strbuf *line)
|
static void decode_transfer_encoding(struct strbuf *line)
|
||||||
|
Loading…
Reference in New Issue
Block a user