#endif
#ifdef HAVE_PGP
- if (cur->security & APPLICATION_PGP && (cmflags & M_CM_VERIFY))
+ if ((cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY))
mutt_message ((cur->security & GOODSIGN) ?
_("PGP signature successfully verified.") :
_("PGP signature could NOT be verified."));
case OP_COMPOSE_TOGGLE_RECODE:
{
CHECK_COUNT;
- if (!mutt_is_text_type (CURRENT->type, CURRENT->subtype))
+ if (!mutt_is_text_part (CURRENT))
{
mutt_error (_("Recoding only affects text attachments."));
break;
# breaking PGP/MIME.
# decode application/pgp
-set pgp_decode_command="/usr/bin/gpg %?p?--passphrase-fd 0? --no-verbose --quiet --batch --output - %f"
+set pgp_decode_command="/usr/bin/gpg --charset utf-8 %?p?--passphrase-fd 0? --no-verbose --quiet --batch --output - %f"
# verify a pgp/mime signature
set pgp_verify_command="/usr/bin/gpg --no-verbose --quiet --batch --output - --verify %s %f"
# create a application/pgp signed (old-style) message
# set pgp_clearsign_command="/usr/bin/gpg-2comp --comment '' --no-verbose --batch --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
-set pgp_clearsign_command="/usr/bin/gpg --no-verbose --batch --quiet --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
+set pgp_clearsign_command="/usr/bin/gpg --charset utf-8 --no-verbose --batch --quiet --output - --passphrase-fd 0 --armor --textmode --clearsign %?a?-u %a? %f"
# create a pgp/mime encrypted attachment
# set pgp_encrypt_only_command="pgpewrap gpg-2comp -v --batch --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f"
-set pgp_encrypt_only_command="pgpewrap /usr/bin/gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f"
+set pgp_encrypt_only_command="pgpewrap /usr/bin/gpg --charset utf-8 --batch --quiet --no-verbose --output - --encrypt --textmode --armor --always-trust -- -r %r -- %f"
# create a pgp/mime encrypted and signed attachment
# set pgp_encrypt_sign_command="pgpewrap gpg-2comp --passphrase-fd 0 -v --batch --output - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f"
-set pgp_encrypt_sign_command="pgpewrap /usr/bin/gpg --passphrase-fd 0 --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f"
+set pgp_encrypt_sign_command="pgpewrap /usr/bin/gpg --charset utf-8 --passphrase-fd 0 --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --always-trust -- -r %r -- %f"
# import a key into the public key ring
set pgp_import_command="/usr/bin/gpg --no-verbose --import -v %f"
if (msg->security & APPLICATION_PGP)
{
if ((msg->content->type == TYPETEXT) &&
- !ascii_strcasecmp (msg->content->subtype, "plain") &&
- ((flags & ENCRYPT) || (msg->content->content && msg->content->content->hibin == 0)))
+ !ascii_strcasecmp (msg->content->subtype, "plain"))
{
- if ((i = query_quadoption (OPT_PGPTRADITIONAL, _("Create an application/pgp message?"))) == -1)
+ if ((i = query_quadoption (OPT_PGPTRADITIONAL, _("Create an inline PGP message?"))) == -1)
return -1;
else if (i == M_YES)
traditional = 1;
}
#ifdef HAVE_PGP
else if (m->type == TYPETEXT)
+ {
t |= mutt_is_application_pgp (m);
+ if (t && m->goodsig)
+ t |= GOODSIGN;
+ }
#endif
mutt_unlink (tempfile);
b->goodsig = goodsig;
- b->badsig = goodsig;
+ b->badsig = goodsig; /* XXX - WHAT!?!?!? */
/* Now display the signed body */
state_attach_puts (_("[-- The following data is signed --]\n\n"), s);
void mutt_decode_attachment (BODY *b, STATE *s)
{
- int istext = mutt_is_text_type (b->type, b->subtype);
+ int istext = mutt_is_text_part (b);
iconv_t cd = (iconv_t)(-1);
if (istext && s->flags & M_CHARCONV)
/* see if we need to decode this part before processing it */
if (b->encoding == ENCBASE64 || b->encoding == ENCQUOTEDPRINTABLE ||
b->encoding == ENCUUENCODED || plaintext ||
- mutt_is_text_type (b->type, b->subtype)) /* text subtypes may
+ mutt_is_text_part (b)) /* text subtypes may
* require character
* set conversion even
* with 8bit encoding.
b->use_disp = use_disp;
b->unlink = 1;
- if (mutt_is_text_type (b->type, b->subtype))
+ if (mutt_is_text_part (b))
b->noconv = 1;
b->xtype = safe_strdup (b->xtype);
return 1;
}
-int mutt_is_text_type (int t, char *s)
+int mutt_is_text_part (BODY *b)
{
+ int t = b->type;
+ char *s = b->subtype;
+
+
+#ifdef HAVE_PGP
+ if (mutt_is_application_pgp (b))
+ return 0;
+#endif
if (t == TYPETEXT)
return 1;
state_attach_puts (_("[-- BEGIN PGP SIGNED MESSAGE --]\n\n"), s);
}
- /* Use PGP's output if there was no clearsig signature. */
-
+ /*
+ * Use PGP's output if there was no clearsig signature.
+ * Assume it's utf-8.
+ */
+
if(!clearsign && pgpout)
{
+ int c;
+ FGETCONV *fc;
+
fflush (pgpout);
rewind (pgpout);
- while (fgets (buf, sizeof (buf) - 1, pgpout) != NULL)
+
+ fc = fgetconv_open (pgpout, "utf-8", Charset, M_ICONV_HOOK_TO);
+ while ((c = fgetconv (fc)) != EOF)
{
- if (s->prefix)
+ state_putc (c, s);
+ if (c == '\n' && s->prefix)
state_puts (s->prefix, s);
- state_puts (buf, s);
}
+ fgetconv_close (&fc);
}
/* Close the temporary files iff they were created.
char pgperrfile[_POSIX_PATH_MAX];
char pgpinfile[_POSIX_PATH_MAX];
- char send_charset[STRING];
+ const char *send_charset;
FILE *pgpout = NULL, *pgperr = NULL, *pgpin = NULL;
FILE *fp;
return NULL;
}
- mutt_copy_stream (fp, pgpin);
- fclose (fp);
+ if (!mutt_is_us_ascii (Charset))
+ {
+ int c;
+ FGETCONV *fc;
+
+ if (flags & ENCRYPT)
+ send_charset = "us-ascii";
+ else
+ send_charset = "utf-8";
+
+ fc = fgetconv_open (fp, Charset, "utf-8", M_ICONV_HOOK_FROM);
+ while ((c = fgetconv (fc)) != EOF)
+ fputc (c, pgpin);
+
+ fgetconv_close (&fc);
+ }
+ else
+ {
+ send_charset = "us-ascii";
+ mutt_copy_stream (fp, pgpin);
+ }
+ safe_fclose (&fp);
fclose (pgpin);
mutt_mktemp (pgpoutfile);
b->type = TYPETEXT;
b->subtype = safe_strdup ("plain");
- mutt_set_parameter ("x-mutt-action", flags & ENCRYPT ? "pgp-encrypt" : "pgp-sign",
- &b->parameter);
- mutt_set_parameter ("charset", mutt_get_body_charset (send_charset,
- sizeof (send_charset), a),
+ mutt_set_parameter ("x-action", flags & ENCRYPT ? "pgp-encrypt" : "pgp-sign",
&b->parameter);
+ mutt_set_parameter ("charset", send_charset, &b->parameter);
b->filename = safe_strdup (pgpoutfile);
b->unlink = 1;
b->use_disp = 1;
+ b->noconv = 1;
+
+ if (!(flags & ENCRYPT))
+ b->encoding = a->encoding;
+
return b;
}
int mutt_is_list_cc (int, ADDRESS *, ADDRESS *);
int mutt_is_list_recipient (int, ADDRESS *, ADDRESS *);
int mutt_is_subscribed_list (ADDRESS *);
-int mutt_is_text_type (int, char *);
+int mutt_is_text_part (BODY *);
int mutt_is_valid_mailbox (const char *);
int mutt_lookup_mime_type (BODY *, const char *);
int mutt_messages_in_thread (CONTEXT *, HEADER *, int);
case 'C':
if (!optional)
{
- if (mutt_is_text_type (aptr->content->type, aptr->content->subtype) &&
+ if (mutt_is_text_part (aptr->content) &&
mutt_get_body_charset (charset, sizeof (charset), aptr->content))
mutt_format_s (dest, destlen, prefix, charset);
else
mutt_format_s (dest, destlen, prefix, "");
}
- else if (!mutt_is_text_type (aptr->content->type, aptr->content->subtype) ||
+ else if (!mutt_is_text_part (aptr->content) ||
!mutt_get_body_charset (charset, sizeof (charset), aptr->content))
optional = 0;
break;
fc = fgetconv_open (fpin, 0, 0, 0);
if (a->encoding == ENCQUOTEDPRINTABLE)
- encode_quoted (fc, f, mutt_is_text_type (a->type, a->subtype));
+ encode_quoted (fc, f, mutt_is_text_part (a));
else if (a->encoding == ENCBASE64)
- encode_base64 (fc, f, mutt_is_text_type (a->type, a->subtype));
+ encode_base64 (fc, f, mutt_is_text_part (a));
else if (a->type == TYPETEXT && (!a->noconv))
- encode_8bit (fc, f, mutt_is_text_type (a->type, a->subtype));
+ encode_8bit (fc, f, mutt_is_text_part (a));
else
mutt_copy_stream (fpin, f);