mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
gpg-mail-type: Assume text/plain for missing content-type.
* tools/gpg-mail-tube.c (mail_tube_encrypt): Rename var ct_text for clarity. Replace debug diagnostic by log_info. Assume text/plain for missing content-type. -- Without this fix we would create message/rfc822 attachment instead of a text/plain attachment with the encrypted body.
This commit is contained in:
parent
b389e04ef5
commit
567fb6eaa0
@ -429,7 +429,7 @@ mail_tube_encrypt (estream_t fpin, strlist_t recipients)
|
|||||||
gpgrt_process_t proc = NULL;
|
gpgrt_process_t proc = NULL;
|
||||||
int exitcode;
|
int exitcode;
|
||||||
int i, found;
|
int i, found;
|
||||||
int ct_text = 0;
|
int ct_is_text = 0;
|
||||||
|
|
||||||
ctx->msg = rfc822parse_open (mail_tube_message_cb, ctx);
|
ctx->msg = rfc822parse_open (mail_tube_message_cb, ctx);
|
||||||
if (!ctx->msg)
|
if (!ctx->msg)
|
||||||
@ -502,9 +502,12 @@ mail_tube_encrypt (estream_t fpin, strlist_t recipients)
|
|||||||
const char *media;
|
const char *media;
|
||||||
|
|
||||||
field = rfc822parse_parse_field (ctx->msg, "Content-Type", -1);
|
field = rfc822parse_parse_field (ctx->msg, "Content-Type", -1);
|
||||||
if (field && (media = rfc822parse_query_media_type (field, NULL))
|
if (!field)
|
||||||
&& !strcmp (media, "text"))
|
ct_is_text = 1; /* Assumed CT is text/plain. */
|
||||||
ct_text = 1;
|
else if ((media = rfc822parse_query_media_type (field, NULL))
|
||||||
|
&& !strcmp (media, "text"))
|
||||||
|
ct_is_text = 1;
|
||||||
|
|
||||||
rfc822parse_release_field (field);
|
rfc822parse_release_field (field);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,14 +560,14 @@ mail_tube_encrypt (estream_t fpin, strlist_t recipients)
|
|||||||
"\r\n"
|
"\r\n"
|
||||||
"--=-=mt-%s=-=\r\n",
|
"--=-=mt-%s=-=\r\n",
|
||||||
boundary,
|
boundary,
|
||||||
ct_text? "file":"message",
|
ct_is_text? "file":"message",
|
||||||
boundary);
|
boundary);
|
||||||
if (ct_text)
|
if (ct_is_text)
|
||||||
es_fprintf (es_stdout,
|
es_fprintf (es_stdout,
|
||||||
"Content-Type: text/plain; charset=us-ascii\r\n"
|
"Content-Type: text/plain; charset=us-ascii\r\n"
|
||||||
"Content-Description: PGP encrypted file\r\n"
|
"Content-Description: PGP encrypted file\r\n"
|
||||||
"Content-Disposition: attachment; filename=\"%s\"\r\n"
|
"Content-Disposition: attachment; filename=\"%s\"\r\n"
|
||||||
"\r\n", "pgp-encrypted-file.asc");
|
"\r\n", "pgp-encrypted-file.txt.asc");
|
||||||
else
|
else
|
||||||
es_fprintf (es_stdout,
|
es_fprintf (es_stdout,
|
||||||
"Content-Type: message/rfc822\r\n"
|
"Content-Type: message/rfc822\r\n"
|
||||||
@ -596,18 +599,19 @@ mail_tube_encrypt (estream_t fpin, strlist_t recipients)
|
|||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt.as_attach && ct_text)
|
if (opt.as_attach && ct_is_text)
|
||||||
{
|
{
|
||||||
/* No headers at all; write as plain file and ignore the encoding. */
|
/* No headers at all; write as plain file and ignore the encoding. */
|
||||||
/* FIXME: Should we do a base64 or QP decoding? */
|
/* FIXME: Should we do a base64 or QP decoding? */
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Write new mime headers using the old content-* values. */
|
/* Write new mime headers using the original content-* values. */
|
||||||
for (i=0; i < DIM (ct_names); i++)
|
for (i=0; i < DIM (ct_names); i++)
|
||||||
{
|
{
|
||||||
line = rfc822parse_get_field (ctx->msg, ct_names[i], -1, NULL);
|
line = rfc822parse_get_field (ctx->msg, ct_names[i], -1, NULL);
|
||||||
log_debug ("OLD CT is '%s'\n", line);
|
if (opt.verbose)
|
||||||
|
log_info ("original Content-type is '%s'\n", line);
|
||||||
if (line)
|
if (line)
|
||||||
{
|
{
|
||||||
es_fprintf (gpginfp, "%s\r\n", line);
|
es_fprintf (gpginfp, "%s\r\n", line);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user