if (a->type == TYPEMULTIPART)
{
if (a->encoding != ENC7BIT)
- {
a->encoding = ENC7BIT;
- convert_to_7bit (a->parts);
- }
+ if (option (OPTPGPSTRICTENC))
+ convert_to_7bit (a->parts);
}
else if (a->type == TYPEMESSAGE
&& strcasecmp(a->subtype, "delivery-status"))
}
}
-BODY *pgp_sign_message (BODY *a)
+static BODY *pgp_sign_message (BODY *a)
{
PARAMETER *p;
BODY *t;
/* Warning: "a" is no longer free()d in this routine, you need
* to free() it later. This is necessary for $fcc_attach. */
-BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
+static BODY *pgp_encrypt_message (BODY *a, char *keylist, int sign)
{
char buf[LONG_STRING];
char tempfile[_POSIX_PATH_MAX], pgperrfile[_POSIX_PATH_MAX];
return (t);
}
-int pgp_protect (HEADER *msg, char **pgpkeylist)
+int pgp_get_keys (HEADER *msg, char **pgpkeylist)
{
- BODY *pbody = NULL;
-
/* Do a quick check to make sure that we can find all of the encryption
* keys if the user has requested this service.
*/
set_option (OPTPGPCHECKTRUST);
+ *pgpkeylist = NULL;
if (msg->pgp & PGPENCRYPT)
{
- if ((*pgpkeylist = pgp_findKeys (msg->env->to, msg->env->cc, msg->env->bcc)) == NULL)
+ if ((*pgpkeylist = pgp_findKeys (msg->env->to, msg->env->cc,
+ msg->env->bcc)) == NULL)
return (-1);
}
+ return (0);
+}
+
+int pgp_protect (HEADER *msg, char *pgpkeylist)
+{
+ BODY *pbody = NULL;
+
if ((msg->pgp & PGPSIGN) && !pgp_valid_passphrase ())
return (-1);
- endwin ();
+ if (!isendwin ())
+ endwin ();
if (msg->pgp & PGPENCRYPT)
- {
- pbody = pgp_encrypt_message (msg->content, *pgpkeylist, msg->pgp & PGPSIGN);
- if (!pbody)
- {
- FREE (pgpkeylist);
- return (-1);
- }
- }
+ pbody = pgp_encrypt_message (msg->content, pgpkeylist, msg->pgp & PGPSIGN);
else if (msg->pgp & PGPSIGN)
- {
- if ((pbody = pgp_sign_message (msg->content)) == NULL)
- return (-1);
- }
+ pbody = pgp_sign_message (msg->content);
+
+ if (!pbody)
+ return (-1);
msg->content = pbody;
- return 0;
+ return (0);
}
#endif /* _PGPPATH */
BODY *pgp_decrypt_part (BODY *, STATE *, FILE *);
-BODY *pgp_encrypt_message (BODY *, char *, int);
BODY *pgp_make_key_attachment (char *);
-BODY *pgp_sign_message (BODY *);
const char *pgp_pkalg_to_mic(const char *);
char *pgp_ask_for_key (struct pgp_vinfo *, KEYINFO *, char *, char *, short, char **);
-
char *pgp_keyid(KEYINFO *);
char *_pgp_keyid(KEYINFO *);
int mutt_check_pgp (HEADER *h);
int mutt_parse_pgp_hdr (char *, int);
-int pgp_protect (HEADER *, char **);
+int pgp_get_keys (HEADER *, char **);
+int pgp_protect (HEADER *, char *);
int pgp_query (BODY *);
int pgp_valid_passphrase (void);
if (msg->content->next)
msg->content = mutt_make_multipart (msg->content);
+ /* Ok, we need to do it this way instead of handling all fcc stuff in
+ * one place in order to avoid going to main_loop with encoded "env"
+ * in case of error. Ugh.
+ */
#ifdef _PGPPATH
if (msg->pgp)
{
+ if (pgp_get_keys (msg, &pgpkeylist) == -1)
+ goto main_loop;
+
/* save the decrypted attachments */
save_content = msg->content;
- if (pgp_protect (msg, &pgpkeylist) == -1)
+ if (pgp_protect (msg, pgpkeylist) == -1)
{
if (msg->content->parts)
{
pbody->parts = NULL;
mutt_free_body (&pbody);
}
+ if (pgpkeylist)
+ FREE (&pgpkeylist);
goto main_loop;
}
}
#endif /* _PGPPATH */
- if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
+ if (!option (OPTNOCURSES) && !(flags & SENDMAILX))
mutt_message ("Sending message...");
mutt_prepare_envelope (msg->env);
{
if (save_content->type == TYPEMULTIPART)
{
- if (!isendwin())
- endwin ();
+ if (!(msg->pgp & PGPENCRYPT) && (msg->pgp & PGPSIGN))
+ {
+ /* save initial signature and attachments */
+ save_sig = msg->content->parts->next;
+ save_parts = msg->content->parts->parts->next;
+ }
+
+ /* this means writing only the main part */
+ msg->content = save_content->parts;
+
+ if (pgp_protect (msg, pgpkeylist) == -1)
+ {
+ /* we can't do much about it at this point, so
+ * fallback to saving the whole thing to fcc
+ */
+ msg->content = tmpbody;
+ save_sig = NULL;
+ goto full_fcc;
+ }
+
if (msg->pgp & PGPENCRYPT)
{
- /* encrypt the main part again */
- msg->content = pgp_encrypt_message (save_content->parts,
- pgpkeylist, msg->pgp & PGPSIGN);
/* not released in pgp_encrypt_message() */
mutt_free_body (&save_content->parts);
- encode_descriptions (msg->content);
+ /* make sure we release the right thing later */
save_content->parts = msg->content;
+
+ encode_descriptions (msg->content);
}
else
- {
- /* save initial signature and attachments */
- save_sig = msg->content->parts->next;
- save_parts = msg->content->parts->parts->next;
- /* sign the main part without attachments */
- msg->content = pgp_sign_message (save_content->parts);
save_content = msg->content;
- }
}
}
else
msg->content = msg->content->parts;
}
+full_fcc:
if (msg->content)
mutt_write_fcc (fcc, msg, NULL, 0);
msg->content = tmpbody;
+
#ifdef _PGPPATH
if (save_sig)
{
mutt_free_body (&save_content->parts->next);
save_content->parts = NULL;
mutt_free_body (&save_content);
+
/* restore old signature and attachments */
msg->content->parts->next = save_sig;
msg->content->parts->parts->next = save_parts;