summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alpine/mailcmd.c28
-rw-r--r--alpine/mailcmd.h2
-rw-r--r--alpine/mailpart.c19
-rw-r--r--pith/detach.c11
-rw-r--r--pith/detach.h2
-rw-r--r--pith/pine.hlp20
6 files changed, 71 insertions, 11 deletions
diff --git a/alpine/mailcmd.c b/alpine/mailcmd.c
index 2fcd2165..9a37e7b4 100644
--- a/alpine/mailcmd.c
+++ b/alpine/mailcmd.c
@@ -4143,6 +4143,7 @@ fini:
* existence at all. Don't use this
* together with GE_NO_APPEND.
* GE_ALLPARTS - Turn on AllParts toggle.
+ * GE_BINARY - Turn on Binary toggle.
*
* Returns: -1 cancelled
* -2 prohibited by VAR_OPER_DIR
@@ -4160,7 +4161,7 @@ get_export_filename(struct pine *ps, char *filename, char *deefault,
char precolon[MAXPATH+1], postcolon[MAXPATH+1];
char filename2[MAXPATH+1], tmp[MAXPATH+1], *fn, *ill;
int l, i, ku = -1, r, fatal, homedir = 0, was_abs_path=0, avail, ret = 0;
- int allparts = 0;
+ int allparts = 0, binary = 0;
char prompt_buf[400];
char def[500];
ESCKEY_S *opts = NULL;
@@ -4179,6 +4180,9 @@ get_export_filename(struct pine *ps, char *filename, char *deefault,
if(flags & GE_ALLPARTS)
i++;
+ if(flags & GE_BINARY)
+ i++;
+
opts = (ESCKEY_S *) fs_get((i+1) * sizeof(*opts));
memset(opts, 0, (i+1) * sizeof(*opts));
@@ -4198,6 +4202,14 @@ get_export_filename(struct pine *ps, char *filename, char *deefault,
opts[i++].label = N_("AllParts");
}
+ if(flags & GE_BINARY){
+ binary = i;
+ opts[i].ch = ctrl('R');
+ opts[i].rval = 15;
+ opts[i].name = "^R";
+ opts[i++].label = N_("Binary");
+ }
+
if(history){
opts[i].ch = KEY_UP;
opts[i].rval = 30;
@@ -4636,6 +4648,20 @@ get_export_filename(struct pine *ps, char *filename, char *deefault,
continue;
}
#endif
+ else if(r == 15){ /* toggle Binary bit */
+ if(rflags){
+ if(*rflags & GER_BINARY){
+ *rflags &= ~GER_BINARY;
+ opts[binary].label = N_("Binary");
+ }
+ else{
+ *rflags |= GER_BINARY;
+ opts[binary].label = N_("No Binary");
+ }
+ }
+
+ continue;
+ }
else if(r == 1){ /* Cancel */
ret = -1;
goto done;
diff --git a/alpine/mailcmd.h b/alpine/mailcmd.h
index 3a945bbd..e0f31d3b 100644
--- a/alpine/mailcmd.h
+++ b/alpine/mailcmd.h
@@ -43,11 +43,13 @@
#define GE_NO_APPEND 0x04 /* No appending to file allowed */
#define GE_IS_IMPORT 0x08 /* No writing of file */
#define GE_ALLPARTS 0x10 /* Add AllParts toggle to options */
+#define GE_BINARY 0x20 /* Enable binary download */
#define GER_NONE 0x00 /* get_export_filename return flags */
#define GER_OVER 0x01 /* overwrite of existing file */
#define GER_APPEND 0x02 /* append of existing file */
#define GER_ALLPARTS 0x04 /* AllParts toggle is on */
+#define GER_BINARY 0x08 /* Binary download enabled */
#define CAC_NONE 0x00 /* flags for choose_a_charset */
diff --git a/alpine/mailpart.c b/alpine/mailpart.c
index be16f6dd..462c02e3 100644
--- a/alpine/mailpart.c
+++ b/alpine/mailpart.c
@@ -1293,7 +1293,7 @@ write_attachment(int qline, long int msgno, ATTACH_S *a, char *method)
{
char filename[MAXPATH+1], full_filename[MAXPATH+1],
title_buf[64], *err;
- int r, rflags = GER_NONE, we_cancel = 0;
+ int r, rflags = GER_NONE, we_cancel = 0, flags;
static HISTORY_S *history = NULL;
static ESCKEY_S att_save_opts[] = {
{ctrl('T'), 10, "^T", N_("To Files")},
@@ -1330,9 +1330,12 @@ write_attachment(int qline, long int msgno, ATTACH_S *a, char *method)
snprintf(title_buf, sizeof(title_buf), "%s ATTACHMENT", method);
title_buf[sizeof(title_buf)-1] = '\0';
+ flags = (a && a->body && a->body->type == TYPETEXT ? GE_BINARY : 0)
+ | GE_SEQ_SENSITIVE;
+
r = get_export_filename(ps_global, filename, NULL, full_filename,
sizeof(filename), "attachment", title_buf,
- att_save_opts, &rflags, qline, GE_SEQ_SENSITIVE, &history);
+ att_save_opts, &rflags, qline, flags, &history);
if(r < 0){
switch(r){
@@ -1440,7 +1443,7 @@ int
write_attachment_to_file(MAILSTREAM *stream, long int msgno, ATTACH_S *a, int flags, char *file)
{
char *l_string, sbuf[256], *err;
- int is_text, we_cancel = 0;
+ int is_text, we_cancel = 0, dt_flags = 0, so_flags;
long len, orig_size;
gf_io_t pc;
STORE_S *store;
@@ -1454,7 +1457,13 @@ write_attachment_to_file(MAILSTREAM *stream, long int msgno, ATTACH_S *a, int fl
if(flags & GER_APPEND)
orig_size = name_file_size(file);
- store = so_get(FileStar, file, WRITE_ACCESS | (is_text ? WRITE_TO_LOCALE : 0));
+ if(flags & GER_BINARY)
+ dt_flags |= DT_BINARY;
+
+ so_flags = (is_text & !(flags & GER_BINARY) ? WRITE_TO_LOCALE : 0)
+ | WRITE_ACCESS ;
+
+ store = so_get(FileStar, file, so_flags);
if(store == NULL){
q_status_message2(SM_ORDER | SM_DING, 3, 5,
/* TRANSLATORS: Error opening destination <filename>: <error text> */
@@ -1468,7 +1477,7 @@ write_attachment_to_file(MAILSTREAM *stream, long int msgno, ATTACH_S *a, int fl
we_cancel = init_att_progress(sbuf, stream, a->body);
gf_set_so_writec(&pc, store);
- err = detach(stream, msgno, a->number, 0L, &len, pc, NULL, 0);
+ err = detach(stream, msgno, a->number, 0L, &len, pc, NULL, dt_flags);
gf_clear_so_writec(store);
if(we_cancel)
diff --git a/pith/detach.c b/pith/detach.c
index 0e0a07be..9befeb72 100644
--- a/pith/detach.c
+++ b/pith/detach.c
@@ -202,7 +202,7 @@ detach(MAILSTREAM *stream, /* c-client stream to use */
}
/* convert all text to UTF-8 */
- if(is_text){
+ if(is_text & !(flags & DT_BINARY)){
charset = parameter_val(body->parameter, "charset");
/*
@@ -261,7 +261,9 @@ detach(MAILSTREAM *stream, /* c-client stream to use */
* a multipart segment since an external handler's going to have to
* make sense of it...
*/
- if(is_text || body->type == TYPEMESSAGE || body->type == TYPEMULTIPART)
+ if((is_text & !(flags & DT_BINARY))
+ || body->type == TYPEMESSAGE
+ || body->type == TYPEMULTIPART)
gf_link_filter(gf_nvtnl_local, NULL);
/*
@@ -296,7 +298,7 @@ detach(MAILSTREAM *stream, /* c-client stream to use */
FILTLIST_S *p, *aux = NULL;
size_t count;
- if(aux_filters){
+ if(aux_filters && !(flags & DT_BINARY)){
/* insert NL conversion filters around remaining aux_filters
* so they're not tripped up by local NL convention
*/
@@ -336,7 +338,8 @@ detach(MAILSTREAM *stream, /* c-client stream to use */
for( ; aux_filters->filter ; aux_filters++)
gf_link_filter(aux_filters->filter, aux_filters->data);
- gf_link_filter(gf_nvtnl_local, NULL);
+ if(!(flags & DT_BINARY))
+ gf_link_filter(gf_nvtnl_local, NULL);
}
if((status = gf_pipe(gc, pc)) != NULL){ /* Second pass, sheesh */
diff --git a/pith/detach.h b/pith/detach.h
index 5fb0db4c..1ba90730 100644
--- a/pith/detach.h
+++ b/pith/detach.h
@@ -57,7 +57,7 @@ extern FETCH_READC_S *g_fr_desc;
*/
#define DT_NODFILTER (long) 0x10000
#define DT_NOINTR (long) 0x20000
-
+#define DT_BINARY (long) 0x40000
/* exported protoypes */
char *detach_raw(MAILSTREAM *, long, char *, gf_io_t, int);
diff --git a/pith/pine.hlp b/pith/pine.hlp
index 08e57b91..e0411029 100644
--- a/pith/pine.hlp
+++ b/pith/pine.hlp
@@ -181,11 +181,14 @@ Additions include:
<UL>
<LI> Ignore message from smtp server after a successful authentication
challenge.
+
<LI> If SSLDIR is defined somehow, do not disable S/MIME if the
SSLCERTSDIR is not found.
+
<LI> When Alpine sends an attachment, it will set the boundary attribute
in lower case, as some SMTP servers, such as those of libero.it
reject messages if the boundary attribute is in uppercase.
+
<LI> SMIME: The ^E command that gives infromation on the certificate
is only available for messages that have a signed or encrypted
part.
@@ -232,6 +235,14 @@ Additions include:
<LI> Change in logic in imap_set_password function to make Alpine ask if
a user wants to save a password before reading the password file.
+
+ <LI> Add the Control-R subcommand to the save command for attachments.
+ This subcommand toggles if the saving will be done in binary mode
+ for text attachments. When a user saves an attachment using binary
+ mode it will be saved as it was sent, otherwise the attachment will
+ be transformed to UTF-8 for further transformation through internal
+ and user defined filters for saving.
+
</UL>
@@ -6724,6 +6735,15 @@ This subcommand will only be visible if the message actually has attachments.
You may also View the attachment list and save individual attachments from
there.
<P>
+If you are SAVING a text part (text/plain, text/html, etc.) you can use
+the Control-R subcommand to toggle if saving will be done in binary mode,
+meaning that the attachment will be decoded, but will not be transformed
+to UTF-8 for further processing (either in internal filters, or user
+supplied filters.) This is useful in case you either want to preserve
+the text as it was encoded originally to you, or the attachment was
+incorrectly attached (the attachment is not of text type) and you need
+the original text to process the attachment.
+<P>
You may cancel the Export operation by typing &quot;^C&quot; after exiting
this help.
<P>