diff options
-rw-r--r-- | attach.c | 46 | ||||
-rw-r--r-- | doc/manual.sgml.head | 22 | ||||
-rw-r--r-- | doc/muttrc.man.head | 10 | ||||
-rw-r--r-- | globals.h | 1 | ||||
-rw-r--r-- | init.h | 2 | ||||
-rw-r--r-- | protos.h | 2 | ||||
-rw-r--r-- | rfc1524.c | 2 | ||||
-rw-r--r-- | sendlib.c | 8 |
8 files changed, 84 insertions, 9 deletions
@@ -325,6 +325,41 @@ static int is_mmnoask (const char *buf) return (0); } +void mutt_check_lookup_list (BODY *b, char *type, int len) +{ + LIST *t = MimeLookupList; + int i; + + for (; t; t = t->next) { + i = mutt_strlen (t->data) - 1; + if ((i > 0 && t->data[i-1] == '/' && t->data[i] == '*' && + ascii_strncasecmp (type, t->data, i) == 0) || + ascii_strcasecmp (type, t->data) == 0) { + + BODY tmp = {0}; + int n; + if ((n = mutt_lookup_mime_type (&tmp, b->filename)) != TYPEOTHER) { + snprintf (type, len, "%s/%s", + n == TYPEAUDIO ? "audio" : + n == TYPEAPPLICATION ? "application" : + n == TYPEIMAGE ? "image" : + n == TYPEMESSAGE ? "message" : + n == TYPEMODEL ? "model" : + n == TYPEMULTIPART ? "multipart" : + n == TYPETEXT ? "text" : + n == TYPEVIDEO ? "video" : "other", + tmp.subtype); + dprint(1, (debugfile, "mutt_check_lookup_list: \"%s\" -> %s\n", + b->filename, type)); + } + if (tmp.subtype) + safe_free ((void **) &tmp.subtype); + if (tmp.xtype) + safe_free ((void **) &tmp.xtype); + } + } +} + int mutt_is_autoview (BODY *b, const char *type) { LIST *t = AutoViewList; @@ -332,10 +367,12 @@ int mutt_is_autoview (BODY *b, const char *type) int i; if (!type) - { snprintf (_type, sizeof (_type), "%s/%s", TYPE (b), b->subtype); - type = _type; - } + else + strncpy (_type, type, sizeof(_type)); + + mutt_check_lookup_list (b, _type, sizeof(_type)); + type = _type; if (mutt_needs_mailcap (b)) { @@ -346,8 +383,7 @@ int mutt_is_autoview (BODY *b, const char *type) return 1; } - for (; t; t = t->next) - { + for (; t; t = t->next) { i = mutt_strlen (t->data) - 1; if ((i > 0 && t->data[i-1] == '/' && t->data[i] == '*' && ascii_strncasecmp (type, t->data, i) == 0) || diff --git a/doc/manual.sgml.head b/doc/manual.sgml.head index f05d11b4..33a5cbca 100644 --- a/doc/manual.sgml.head +++ b/doc/manual.sgml.head @@ -2809,6 +2809,24 @@ Next, mutt will check if any of the types have a defined that, Mutt will look for any text type. As a last attempt, mutt will look for any type it knows how to handle. +<sect1>MIME Lookup<label id="mime_lookup"> +<p> +Mutt's mime_lookup list specifies a list of mime-types that should not +be treated according to their mailcap entry. This option is designed to +deal with binary types such as application/octet-stream. When an attachment's +mime-type is listed in mime_lookup, then the extension of the filename will +be compared to the list of extensions in the mime.types file. The mime-type +associated with this extension will then be used to process the attachment +according to the rules in the mailcap file and according to any other configuration +options (such as auto_view) specified. Common usage would be: +<tscreen><verb> +mime-lookup application/octet-stream application/X-Lotus-Manuscript +</verb></tscreen> + +In addition, the unmime_lookup command may be used to disable this feature +for any particular mime-type if it had been set, for example, in a global +muttrc. + <sect>Reference <sect1>Command line options<label id="commandline"> <p> @@ -2909,6 +2927,10 @@ The following are the commands understood by mutt. <item> <tt><ref id="message-hook" name="message-hook"></tt> <em/pattern/ <em/command/ <item> +<tt><ref id="mime_lookup" name="mime_lookup"></tt> <em/mimetype/ [ <em/mimetype/ ... ] +<item> +<tt><ref id="mime_lookup" name="unmime_lookup"></tt> <em/mimetype/ [ <em/mimetype/ ... ] +<item> <tt><ref id="color" name="mono"></tt> <em/object attribute/ [ <em/regexp/ ] <item> <tt><ref id="color" name="unmono"></tt> <em/index/ <em/pattern/ [ <em/pattern/ ... ] diff --git a/doc/muttrc.man.head b/doc/muttrc.man.head index 176f30dd..e6905701 100644 --- a/doc/muttrc.man.head +++ b/doc/muttrc.man.head @@ -92,6 +92,16 @@ entry for the given MIME type with the .B copiousoutput flag set. A subtype of \(lq\fB*\fP\(rq matches any subtype, as does an empty subtype. +.PP +.nf +\fBmime_lookup\fP \fItype\fP[\fB/\fP\fIsubtype\fP] [ ... ] +\fBunmime_lookup\fP \fItype\fP[\fB/\fP\fIsubtype\fP] [ ... ] +This command permits you to define a list of "data" MIME content +types for which mutt will try to determine the actual file type from +the file name, and not use a +.BR mailcap (5) +entry given for the original MIME type. For instance, you may add +the \fBapplication/octet-stream\fP MIME type to this list. .TP \fBbind\fP \fImap\fP \fIkey\fP \fIfunction\fP This command binds the given \fIkey\fP for the given \fImap\fP to @@ -118,6 +118,7 @@ WHERE LIST *AutoViewList INITVAL(0); WHERE LIST *AlternativeOrderList INITVAL(0); WHERE LIST *HeaderOrderList INITVAL(0); WHERE LIST *Ignore INITVAL(0); +WHERE LIST *MimeLookupList INITVAL(0); WHERE LIST *UnIgnore INITVAL(0); WHERE LIST *MailLists INITVAL(0); WHERE LIST *SubscribedLists INITVAL(0); @@ -2455,6 +2455,8 @@ struct command_t Commands[] = { { "mailboxes", mutt_parse_mailboxes, 0 }, { "message-hook", mutt_parse_hook, M_MESSAGEHOOK }, { "mbox-hook", mutt_parse_hook, M_MBOXHOOK }, + { "mime_lookup", parse_list, UL &MimeLookupList }, + { "unmime_lookup", parse_unlist, UL &MimeLookupList }, { "mono", mutt_parse_mono, 0 }, { "my_hdr", parse_my_hdr, 0 }, #ifdef HAVE_PGP @@ -190,6 +190,7 @@ void mutt_free_parameter (PARAMETER **); void mutt_generate_header (char *, size_t, HEADER *, int); void mutt_help (int); void mutt_draw_tree (CONTEXT *); +void mutt_check_lookup_list (BODY *, char *, int); void mutt_make_attribution (CONTEXT *ctx, HEADER *cur, FILE *out); void mutt_make_forward_subject (ENVELOPE *env, CONTEXT *ctx, HEADER *cur); void mutt_make_help (char *, size_t, char *, int, int); @@ -288,6 +289,7 @@ int mutt_is_list_recipient (int, ADDRESS *, ADDRESS *); int mutt_is_subscribed_list (ADDRESS *); int mutt_is_text_type (int, char *); int mutt_is_valid_mailbox (const char *); +int mutt_lookup_mime_type (BODY *, const char *); int mutt_messages_in_thread (CONTEXT *, HEADER *, int); int mutt_multi_choice (char *prompt, char *letters); int mutt_needs_mailcap (BODY *); @@ -392,6 +392,8 @@ int rfc1524_mailcap_lookup (BODY *a, char *type, rfc1524_entry *entry, int opt) return 0; } + mutt_check_lookup_list (a, type, SHORT_STRING); + while (!found && *curr) { x = 0; @@ -959,7 +959,7 @@ CONTENT *mutt_get_content_info (const char *fname, BODY *b) * exists. */ -static int lookup_mime_type (BODY *att, const char *path) +int mutt_lookup_mime_type (BODY *att, const char *path) { FILE *f; char *p, *q, *ct; @@ -994,7 +994,7 @@ static int lookup_mime_type (BODY *att, const char *path) strfcpy (buf, PKGDATADIR"/mime.types", sizeof (buf)); break; default: - dprint (1, (debugfile, "lookup_mime_type: Internal error, count = %d.\n", count)); + dprint (1, (debugfile, "mutt_lookup_mime_type: Internal error, count = %d.\n", count)); goto bye; /* shouldn't happen */ } @@ -1376,7 +1376,7 @@ BODY *mutt_make_file_attach (const char *path) #if 0 - if ((n = lookup_mime_type (buf, sizeof (buf), xbuf, sizeof (xbuf), path)) != TYPEOTHER + if ((n = mutt_lookup_mime_type (buf, sizeof (buf), xbuf, sizeof (xbuf), path)) != TYPEOTHER || *xbuf != '\0') { att->type = n; @@ -1386,7 +1386,7 @@ BODY *mutt_make_file_attach (const char *path) #else - lookup_mime_type (att, path); + mutt_lookup_mime_type (att, path); #endif |