diff --git a/alpine/send.c b/alpine/send.c index 6eb3313..ba55d1c 100644 --- a/alpine/send.c +++ b/alpine/send.c @@ -4111,6 +4111,23 @@ pine_send(ENVELOPE *outgoing, struct mail_bodystruct **body, pbf = save_previous_pbuf; g_rolenick = NULL; + /* Topal: Unmangle the body types. */ + if ((*body)->type == TYPEMULTIPART + && (*body)->topal_hack == 1) { + /* This was a single part message which Topal mangled. */ + dprint((9, "Topal: unmangling single part message\n")); + (*body)->type = TYPETEXT; + } + if ((*body)->type == TYPEMULTIPART + && (*body)->topal_hack != 1 + && (*body)->nested.part->body.type == TYPEMULTIPART + && (*body)->nested.part->body.topal_hack == 1) { + /* Topal mangled a multipart message. So the first nested part + is really TYPETEXT. */ + dprint((9, "Topal: unmangling first part of multipart message\n")); + (*body)->nested.part->body.type = TYPETEXT; + } + dprint((4, "=== send returning ===\n")); } @@ -5447,22 +5464,50 @@ filter_message_text(char *fcmd, ENVELOPE *outgoing, struct mail_bodystruct *body rfc822_parse_content_header(nb, (char *) ucase((unsigned char *) buf+8),s); + /* Topal: We're working on the first + text segment of the message. If + the filter returns something that + isn't TYPETEXT, then we need to + pretend (later on) that this is in + fact a TYPETEXT, because Topal has + already encoded it.... + + Original code path first, then an + alternate path. + */ if(nb->type == TYPETEXT && nb->subtype && (!b->subtype || strucmp(b->subtype, nb->subtype))){ - if(b->subtype) - fs_give((void **) &b->subtype); - + if(b->subtype) + fs_give((void **) &b->subtype); + + b->subtype = nb->subtype; + nb->subtype = NULL; + + mail_free_body_parameter(&b->parameter); + b->parameter = nb->parameter; + nb->parameter = NULL; + mail_free_body_parameter(&nb->parameter); + } + else if(F_ON(F_ENABLE_TOPAL_HACK, ps_global)){ + /* Perhaps the type isn't TYPETEXT, + and the hack is requested. So, + let's mess with the types. */ + if(nb->type != TYPETEXT){ + b->type = nb->type; b->subtype = nb->subtype; nb->subtype = NULL; - + + dprint((9, "Topal: mangling body!\n")); mail_free_body_parameter(&b->parameter); b->parameter = nb->parameter; nb->parameter = NULL; mail_free_body_parameter(&nb->parameter); + b->topal_hack = 1; + } } - + /* Topal: end */ mail_free_body(&nb); } diff --git a/imap/src/c-client/mail.c b/imap/src/c-client/mail.c index 8f0373e..8b0dc80 100644 --- a/imap/src/c-client/mail.c +++ b/imap/src/c-client/mail.c @@ -2807,6 +2807,8 @@ BODY *mail_body_section (BODY *b, unsigned char *section) BODY *mail_body (MAILSTREAM *stream,unsigned long msgno,unsigned char *section) { BODY *b = NIL; + /* Topal hack 2 */ + mail_fetchstructure (stream,msgno,&b); /* make sure have a body */ if (section && *section && mail_fetchstructure (stream,msgno,&b) && b) return mail_body_section(b, section); diff --git a/imap/src/c-client/mail.h b/imap/src/c-client/mail.h index 58d2979..70deb46 100644 --- a/imap/src/c-client/mail.h +++ b/imap/src/c-client/mail.h @@ -828,6 +828,7 @@ BODY { unsigned long bytes; /* size of text in octets */ } size; char *md5; /* MD5 checksum */ + unsigned short topal_hack; /* set to 1 if topal has wrecked the sending */ void *sparep; /* spare pointer reserved for main program */ }; diff --git a/pith/conf.c b/pith/conf.c index c7c24db..bb9daa7 100644 --- a/pith/conf.c +++ b/pith/conf.c @@ -2910,6 +2910,8 @@ feature_list(int index) F_SEND_WO_CONFIRM, h_config_send_wo_confirm, PREF_SEND, 0}, {"strip-whitespace-before-send", "Strip Whitespace Before Sending", F_STRIP_WS_BEFORE_SEND, h_config_strip_ws_before_send, PREF_SEND, 0}, + {"enable-topal-hack", "Enable Topal hack for OpenPGP/MIME messages", + F_ENABLE_TOPAL_HACK, h_config_enable_topal_hack, PREF_HIDDEN, 0}, {"warn-if-blank-fcc", "Warn if Blank Fcc", F_WARN_ABOUT_NO_FCC, h_config_warn_if_fcc_blank, PREF_SEND, 0}, {"warn-if-blank-subject", "Warn if Blank Subject", diff --git a/pith/conftype.h b/pith/conftype.h index bfb337c..21b630d 100644 --- a/pith/conftype.h +++ b/pith/conftype.h @@ -522,6 +522,7 @@ typedef enum { F_MARK_FCC_SEEN, F_MULNEWSRC_HOSTNAMES_AS_TYPED, F_STRIP_WS_BEFORE_SEND, + F_ENABLE_TOPAL_HACK, F_QUELL_FLOWED_TEXT, F_COMPOSE_ALWAYS_DOWNGRADE, F_SORT_DEFAULT_FCC_ALPHA, diff --git a/pith/mailcap.c b/pith/mailcap.c index 06a0b63..87a82e7 100644 --- a/pith/mailcap.c +++ b/pith/mailcap.c @@ -583,8 +583,17 @@ mc_get_command(int type, char *subtype, BODY *body, * typically two scans through the check_extension * mechanism, the mailcap entry now takes precedence. */ - if((fname = get_filename_parameter(NULL, 0, body, &e2b.from.ext)) != NULL - && e2b.from.ext && e2b.from.ext[0]){ + /* Topal hack 2 */ + fname = get_filename_parameter(NULL, 0, body, &e2b.from.ext); + if (fname == NULL) { + if (body->type == TYPEMULTIPART && + ((body->subtype && !strucmp(body->subtype, "signed")) + ||(body->subtype && !strucmp(body->subtype, "encrypted")))) + fname = cpystr("openpgp.msg"); + } + + if(fname != NULL + && e2b.from.ext && e2b.from.ext[0]){ if(strlen(e2b.from.ext) < sizeof(tmp_ext) - 2){ strncpy(ext = tmp_ext, e2b.from.ext - 1, sizeof(tmp_ext)); /* remember it */ tmp_ext[sizeof(tmp_ext)-1] = '\0'; diff --git a/pith/pine.hlp b/pith/pine.hlp index 9967019..d2e657d 100644 --- a/pith/pine.hlp +++ b/pith/pine.hlp @@ -4216,7 +4216,8 @@ There are also additional details on
+<End of help on this topic> +