struct CTinfo c_ctinfo; /* parsed elements of Content-Type */
int c_type; /* internal flag for content type */
int c_subtype; /* internal flag for content subtype */
+ char *c_charset; /* charset string */
/* Content-Transfer-Encoding info (decoded contents) */
CE c_cefile; /* structure holding decoded content */
int c_rfc934; /* rfc934 compatibility flag */
char *c_showproc; /* default, if not in profile */
- char *c_termproc; /* for charset madness... */
char *c_storeproc; /* overrides profile entry, if any */
char *c_storage; /* write contents (file) */
ct->c_type, ct->c_subtype,
(unsigned int)(unsigned long) ct->c_ctparams);
+ fprintf(stderr, " charset \"%s\"\n", empty(ct->c_charset));
fprintf(stderr, " showproc \"%s\"\n", empty(ct->c_showproc));
- fprintf(stderr, " termproc \"%s\"\n", empty(ct->c_termproc));
fprintf(stderr, " storeproc \"%s\"\n", empty(ct->c_storeproc));
/* print transfer encoding information */
static int
InitText(CT ct)
{
- char buffer[BUFSIZ];
- char *chset = NULL;
- char **ap, **ep, *cp;
+ char **ap, **ep;
struct k2v *kv;
struct text *t;
CI ci = &ct->c_ctinfo;
/* check if content specified a character set */
if (*ap) {
+ /* store its name */
+ ct->c_charset = getcpy(norm_charmap(*ep));
/* match character set or set to CHARSET_UNKNOWN */
for (kv = Charset; kv->kv_key; kv++) {
if (!mh_strcasecmp(*ep, kv->kv_key)) {
- chset = *ep;
break;
}
}
t->tx_charset = CHARSET_UNSPECIFIED;
}
- /*
- ** If we can not handle character set natively,
- ** then check profile for string to modify the
- ** terminal or display method.
- **
- ** termproc is for mhshow, though mhlist -debug prints it, too.
- */
- if (chset != NULL && !check_charset(chset, strlen(chset))) {
- snprintf(buffer, sizeof(buffer), "%s-charset-%s",
- invo_name, chset);
- if ((cp = context_find(buffer)))
- ct->c_termproc = getcpy(cp);
- }
-
return OK;
}
}
break;
+ case 'c':
+ /* insert charset */
+ if (ct->c_charset) {
+ strncpy(bp, ct->c_charset, buflen);
+ }
+ break;
+
case 'd':
/* insert content description */
if (ct->c_descr) {
}
}
- if (buflen <= 0 || (ct->c_termproc &&
- (size_t)buflen <= strlen(ct->c_termproc))) {
- /*
- ** content_error would provide a more useful error message
- ** here, except that if we got overrun, it probably would
- ** too.
- */
- fprintf(stderr, "Buffer overflow constructing show command!\n");
- return NOTOK;
- }
-
- /* use charset string to modify display method */
- if (ct->c_termproc) {
- char term[BUFSIZ];
-
- strncpy(term, buffer, sizeof(term));
- snprintf(buffer, sizeof(buffer), ct->c_termproc, term);
- }
-
got_command:
return show_content_aux2(ct, alternate, cracked, buffer,
fd, xlist, xstdin, xtty);
** if it is not a text part of a multipart/alternative
*/
if (!alternate || ct->c_subtype == TEXT_PLAIN) {
- snprintf(buffer, sizeof(buffer), "%%p%s '%%F'", defaultpager);
+ if (!check_charset(ct->c_charset, strlen(ct->c_charset))) {
+ snprintf(buffer, sizeof(buffer), "%%liconv -f '%s'",
+ ct->c_charset);
+ } else {
+ snprintf(buffer, sizeof(buffer), "%%lcat");
+ }
cp = (ct->c_showproc = getcpy(buffer));
return show_content_aux(ct, alternate, cp, NULL);
}
}
break;
+ case 'c':
+ /* insert charset */
+ if (ct->c_charset) {
+ strncpy(bp, ct->c_charset, buflen);
+ }
+ break;
+
case 'd':
/* insert content description */
if (ct->c_descr) {
}
}
- if (buflen <= 0 || (ct->c_termproc &&
- (size_t)buflen <= strlen(ct->c_termproc))) {
- /*
- ** content_error would provide a more useful error message
- ** here, except that if we got overrun, it probably would
- ** too.
- */
- fprintf(stderr, "Buffer overflow constructing show command!\n");
- return NOTOK;
- }
-
- /* use charset string to modify display method */
- if (ct->c_termproc) {
- char term[BUFSIZ];
-
- strncpy(term, buffer, sizeof(term));
- snprintf(buffer, sizeof(buffer), ct->c_termproc, term);
- }
-
return show_content_aux2(ct, alternate, NULL, buffer,
NOTOK, xlist, 0, xtty);
}