From 37652c6ff8acf7acb2196371a2c049647fc4b6c5 Mon Sep 17 00:00:00 2001 From: Eduardo Chappa Date: Sun, 31 Jul 2016 20:38:01 -0600 Subject: * 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. --- pith/mimetype.c | 18 ++++++++++++++++++ pith/mimetype.h | 1 + pith/pine.hlp | 6 ++++++ 3 files changed, 25 insertions(+) (limited to 'pith') 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:
  • When selecting messages by number, the "." character can be used to specify the message on which the cursor is on. + +
  • 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. -- cgit v1.2.3-70-g09d2