Merge branch 'jc/mailinfo'
* jc/mailinfo: mailinfo: assume input is latin-1 on the header as we do for the bodymaint
commit
12d4a97a03
|
@ -348,7 +348,7 @@ static void cleanup_space(char *buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void decode_header_bq(char *it);
|
static void decode_header(char *it);
|
||||||
typedef int (*header_fn_t)(char *);
|
typedef int (*header_fn_t)(char *);
|
||||||
struct header_def {
|
struct header_def {
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -371,7 +371,7 @@ static void check_header(char *line, struct header_def *header)
|
||||||
/* Unwrap inline B and Q encoding, and optionally
|
/* Unwrap inline B and Q encoding, and optionally
|
||||||
* normalize the meta information to utf8.
|
* normalize the meta information to utf8.
|
||||||
*/
|
*/
|
||||||
decode_header_bq(line + len + 2);
|
decode_header(line + len + 2);
|
||||||
header[i].func(line + len + 2);
|
header[i].func(line + len + 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -566,16 +566,19 @@ static void convert_to_utf8(char *line, char *charset)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void decode_header_bq(char *it)
|
static int decode_header_bq(char *it)
|
||||||
{
|
{
|
||||||
char *in, *out, *ep, *cp, *sp;
|
char *in, *out, *ep, *cp, *sp;
|
||||||
char outbuf[1000];
|
char outbuf[1000];
|
||||||
|
int rfc2047 = 0;
|
||||||
|
|
||||||
in = it;
|
in = it;
|
||||||
out = outbuf;
|
out = outbuf;
|
||||||
while ((ep = strstr(in, "=?")) != NULL) {
|
while ((ep = strstr(in, "=?")) != NULL) {
|
||||||
int sz, encoding;
|
int sz, encoding;
|
||||||
char charset_q[256], piecebuf[256];
|
char charset_q[256], piecebuf[256];
|
||||||
|
rfc2047 = 1;
|
||||||
|
|
||||||
if (in != ep) {
|
if (in != ep) {
|
||||||
sz = ep - in;
|
sz = ep - in;
|
||||||
memcpy(out, in, sz);
|
memcpy(out, in, sz);
|
||||||
|
@ -589,19 +592,19 @@ static void decode_header_bq(char *it)
|
||||||
ep += 2;
|
ep += 2;
|
||||||
cp = strchr(ep, '?');
|
cp = strchr(ep, '?');
|
||||||
if (!cp)
|
if (!cp)
|
||||||
return; /* no munging */
|
return rfc2047; /* no munging */
|
||||||
for (sp = ep; sp < cp; sp++)
|
for (sp = ep; sp < cp; sp++)
|
||||||
charset_q[sp - ep] = tolower(*sp);
|
charset_q[sp - ep] = tolower(*sp);
|
||||||
charset_q[cp - ep] = 0;
|
charset_q[cp - ep] = 0;
|
||||||
encoding = cp[1];
|
encoding = cp[1];
|
||||||
if (!encoding || cp[2] != '?')
|
if (!encoding || cp[2] != '?')
|
||||||
return; /* no munging */
|
return rfc2047; /* no munging */
|
||||||
ep = strstr(cp + 3, "?=");
|
ep = strstr(cp + 3, "?=");
|
||||||
if (!ep)
|
if (!ep)
|
||||||
return; /* no munging */
|
return rfc2047; /* no munging */
|
||||||
switch (tolower(encoding)) {
|
switch (tolower(encoding)) {
|
||||||
default:
|
default:
|
||||||
return; /* no munging */
|
return rfc2047; /* no munging */
|
||||||
case 'b':
|
case 'b':
|
||||||
sz = decode_b_segment(cp + 3, piecebuf, ep);
|
sz = decode_b_segment(cp + 3, piecebuf, ep);
|
||||||
break;
|
break;
|
||||||
|
@ -610,7 +613,7 @@ static void decode_header_bq(char *it)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (sz < 0)
|
if (sz < 0)
|
||||||
return;
|
return rfc2047;
|
||||||
if (metainfo_charset)
|
if (metainfo_charset)
|
||||||
convert_to_utf8(piecebuf, charset_q);
|
convert_to_utf8(piecebuf, charset_q);
|
||||||
strcpy(out, piecebuf);
|
strcpy(out, piecebuf);
|
||||||
|
@ -619,6 +622,19 @@ static void decode_header_bq(char *it)
|
||||||
}
|
}
|
||||||
strcpy(out, in);
|
strcpy(out, in);
|
||||||
strcpy(it, outbuf);
|
strcpy(it, outbuf);
|
||||||
|
return rfc2047;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void decode_header(char *it)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (decode_header_bq(it))
|
||||||
|
return;
|
||||||
|
/* otherwise "it" is a straight copy of the input.
|
||||||
|
* This can be binary guck but there is no charset specified.
|
||||||
|
*/
|
||||||
|
if (metainfo_charset)
|
||||||
|
convert_to_utf8(it, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void decode_transfer_encoding(char *line)
|
static void decode_transfer_encoding(char *line)
|
||||||
|
|
Loading…
Reference in New Issue