diff options
-rw-r--r-- | alpine/mailpart.c | 10 | ||||
-rw-r--r-- | pith/mimetype.c | 18 | ||||
-rw-r--r-- | pith/mimetype.h | 1 | ||||
-rw-r--r-- | pith/pine.hlp | 6 |
4 files changed, 30 insertions, 5 deletions
diff --git a/alpine/mailpart.c b/alpine/mailpart.c index ac8cdd7d..651786cf 100644 --- a/alpine/mailpart.c +++ b/alpine/mailpart.c @@ -2115,11 +2115,11 @@ display_attachment(long int msgno, ATTACH_S *a, int flags) (void) get_filename_parameter(sender_filename, sizeof(sender_filename), a->body, &extp); - if(!set_mime_extension_by_type(ext, mtype)){ /* extension from type */ - if(extp && extp[0]){ /* extension from filename */ - strncpy(ext, extp, sizeof(ext)); - ext[sizeof(ext)-1] = '\0'; - } + if(check_mime_type_by_extension(extp, mtype) + || (!set_mime_extension_by_type(ext, mtype) /* extension from type */ + && extp && extp[0])){ /* extension from filename */ + strncpy(ext, extp, sizeof(ext)); + ext[sizeof(ext)-1] = '\0'; } /* create a temp file */ diff --git a/pith/mimetype.c b/pith/mimetype.c index a5292269..5b5bed77 100644 --- a/pith/mimetype.c +++ b/pith/mimetype.c @@ -18,6 +18,7 @@ static char rcsid[] = "$Id: mimetype.c 955 2008-03-06 23:52:36Z hubert@u.washing #include "../pith/headers.h" #include "../pith/mimetype.h" +#include "../pith/mimedesc.h" #include "../pith/state.h" #include "../pith/conf.h" #include "../pith/mailcap.h" @@ -92,6 +93,23 @@ set_mime_extension_by_type (char *ext, char *mtype) } +int +check_mime_type_by_extension (char *ext, char *mtype) +{ + MT_MAP_T e2t; + char mimet[128]; + + if((e2t.from.ext = ext) != NULL && *e2t.from.ext + && mt_srch_mime_type(mt_srch_by_ext, &e2t)){ + snprintf(mimet, sizeof(mimet), "%s/%s", + body_type_names(e2t.to.mime.type), e2t.to.mime.subtype); + mimet[sizeof(mimet) - 1] = '\0'; + fs_give((void **)& e2t.to.mime.subtype); + return strucmp(mimet, mtype) ? 0 : 1; + } + + return(0); +} /* diff --git a/pith/mimetype.h b/pith/mimetype.h index 62f2044c..0f06b4b0 100644 --- a/pith/mimetype.h +++ b/pith/mimetype.h @@ -42,6 +42,7 @@ typedef int (* MT_OPERATORPROC)(MT_MAP_T *, FILE *); /* exported protoypes */ int set_mime_type_by_extension(BODY *, char *); int set_mime_extension_by_type(char *, char *); +int check_mime_type_by_extension(char *, char *); int mt_srch_by_ext(MT_MAP_T *, FILE *); int mt_get_file_ext(char *, char **); int mt_srch_mime_type(MT_OPERATORPROC, MT_MAP_T *); diff --git a/pith/pine.hlp b/pith/pine.hlp index a1950964..36d69402 100644 --- a/pith/pine.hlp +++ b/pith/pine.hlp @@ -341,6 +341,12 @@ Additions include: <LI> When selecting messages by number, the "." character can be used to specify the message on which the cursor is on. + + <LI> When Alpine opens an attachment, it sometimes changes the extension + of the file that is being opened and replaces it by another for the + same mime type. If Alpine finds that the extension of the file + corresponds with the mime type, according to the mime-types file, + then it will keep it, and no substitution will be made. </UL> |