** .pp
** \fBNote:\fP This does not apply to IMAP mailboxes, see $$imap_mail_check.
*/
- {"mailcap_path", DT_STR, R_NONE, UL &MailcapPath, "" },
- /*
- ** .pp
- ** This variable specifies which files to consult when attempting to
- ** display MIME bodies not directly supported by Madmutt.
- */
- {"mailcap_sanitize", DT_BOOL, R_NONE, OPTMAILCAPSANITIZE, "yes" },
- /*
- ** .pp
- ** If \fIset\fP, Madmutt will restrict possible characters in mailcap \fT%\fP expandos
- ** to a well-defined set of safe characters. This is the safe setting,
- ** but we are not sure it doesn't break some more advanced MIME stuff.
- ** .pp
- ** \fBDON'T CHANGE THIS SETTING UNLESS YOU ARE REALLY SURE WHAT YOU ARE
- ** DOING!\fP
- */
#ifdef USE_HCACHE
{"header_cache", DT_PATH, R_NONE, UL &HeaderCache, "" },
/*
rx_t *SpamList = NULL, *NoSpamList = NULL;
+static char *mailcap_init(void)
+{
+ /* Default search path from RFC1524 */
+ const char *path = "~/.mailcap:" PKGDATADIR "/mailcap:"
+ SYSCONFDIR "/mailcap:/etc/mailcap:"
+ "/usr/etc/mailcap:/usr/local/etc/mailcap";
+ return m_strdup(getenv("MAILCAPS") ?: path);
+}
+
@package Mime {
/*
** .pp
*/
string_t spam_separator = m_strdup(",");
+ /*
+ ** .pp
+ ** This variable specifies which files to consult when attempting to
+ ** display MIME bodies not directly supported by Madmutt.
+ */
+ string_t mailcap_path = mailcap_init();
+
+ /*
+ ** .pp
+ ** If \fIset\fP, Madmutt will restrict possible characters in mailcap \fT%\fP expandos
+ ** to a well-defined set of safe characters. This is the safe setting,
+ ** but we are not sure it doesn't break some more advanced MIME stuff.
+ ** .pp
+ ** \fBDON'T CHANGE THIS SETTING UNLESS YOU ARE REALLY SURE WHAT YOU ARE
+ ** DOING!\fP
+ */
+ bool mailcap_sanitize = 1;
+
void spam(rx_t rx, const string_t tpl) {
rx_set_template(rx, tpl);
rx_list_remove(&NoSpamList, rx);
/* returns 1 if Mutt can't display this type of data, 0 otherwise */
int rfc1524_mailcap_isneeded(BODY * m)
{
- int tok;
-
switch (m->type) {
case TYPEMULTIPART:
case TYPEMESSAGE:
return !(mutt_is_application_pgp(m) || mutt_is_application_smime(m));
case TYPETEXT:
- tok = mime_which_token(m->subtype, -1);
- if (tok == MIME_PLAIN
- || tok == MIME_RFC822_HEADERS
- || tok == MIME_ENRICHED)
+ switch (mime_which_token(m->subtype, -1)) {
+ case MIME_PLAIN:
+ case MIME_RFC822_HEADERS:
+ case MIME_ENRICHED:
return 0;
- break;
+ default:
+ return 1;
+ }
+ default:
+ return 1;
}
-
- return 1;
}
/* The command semantics include the following:
m_strcpy(type, sizeof(type), mtype);
- if (option(OPTMAILCAPSANITIZE))
+ if (Mime.mailcap_sanitize)
mutt_sanitize_filename(type, 0);
while (command[x] && x < clen && y < ssizeof(buf)) {
m_strcpy(pval, sizeof(pval),
parameter_getval(a->parameter, param));
- if (option(OPTMAILCAPSANITIZE))
+ if (Mime.mailcap_sanitize)
mutt_sanitize_filename(pval, 0);
y += mutt_quote_filename(buf + y, sizeof(buf) - y, pval);
}
-/************** READ MARK **********************/
-
/*
* rfc1524_mailcap_lookup attempts to find the given type in the
* list of mailcap files. On success, this returns the entry information
* in *entry, and returns 1. On failure (not found), returns 0.
* If entry == NULL just return 1 if the given type is found.
*/
-int rfc1524_mailcap_lookup (BODY * a, char *type, rfc1524_entry * entry,
- int opt)
+int rfc1524_mailcap_lookup(BODY *a, char *type, rfc1524_entry *entry, int opt)
{
- char path[_POSIX_PATH_MAX];
- int x;
- int found = FALSE;
- char *curr = MailcapPath;
-
- /* rfc1524 specifies that a path of mailcap files should be searched.
- * joy. They say
- * $HOME/.mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap, etc
- * and overriden by the MAILCAPS environment variable, and, just to be nice,
- * we'll make it specifiable in .muttrc
- */
- if (!curr || !*curr) {
- mutt_error _("No mailcap path specified");
+ const char *p = Mime.mailcap_path;
- return 0;
- }
+ mutt_check_lookup_list(a, type, STRING);
- mutt_check_lookup_list (a, type, STRING);
+ for (;;) {
+ const char *q;
+ char path[_POSIX_PATH_MAX];
- while (!found && *curr) {
- x = 0;
- while (*curr && *curr != ':' && x < ssizeof (path) - 1) {
- path[x++] = *curr;
- curr++;
- }
- if (*curr)
- curr++;
+ while (*p == ':')
+ p++;
- if (!x)
- continue;
+ if (!*p)
+ break;
- path[x] = '\0';
- mutt_expand_path(path, sizeof(path));
+ q = strchrnul(p, ':');
+ m_strncpy(path, sizeof(path), p, q - p);
+ mutt_expand_path(path, sizeof(path));
- found = rfc1524_mailcap_parse (a, path, type, entry, opt);
- }
+ if (rfc1524_mailcap_parse(a, path, type, entry, opt))
+ return 1;
- if (entry && !found)
- mutt_error (_("mailcap entry for type %s not found"), type);
+ p = q;
+ }
+
+ if (entry)
+ mutt_error(_("mailcap entry for type %s not found"), type);
- return found;
+ return 0;
}
+/************** READ MARK **********************/
+
/* This routine will create a _temporary_ filename matching the
* name template given if this needs to be done.