From a9edef00dd65010d4e08517d861ea55992bd863d Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Fri, 1 Jul 2005 03:29:23 +0000 Subject: implement extraction of inline signed/encrypted pgp parts and package them 2005-06-24 Matt Brown * em-inline-filter.c: implement extraction of inline signed/encrypted pgp parts and package them into x-inlinepgp-signed/x-inline-pgp-encrypted parts. * em-format-html.c: Formatters to verify/decrypt and then display the parts generated by the inline filter. svn path=/trunk/; revision=29603 --- mail/em-inline-filter.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'mail/em-inline-filter.c') diff --git a/mail/em-inline-filter.c b/mail/em-inline-filter.c index 40da981d58..38cd013912 100644 --- a/mail/em-inline-filter.c +++ b/mail/em-inline-filter.c @@ -102,6 +102,7 @@ enum { EMIF_BINHEX, EMIF_POSTSCRIPT, EMIF_PGPSIGNED, + EMIF_PGPENCRYPTED, }; const struct { const char *name; @@ -112,7 +113,8 @@ const struct { { "application/octet-stream", CAMEL_TRANSFER_ENCODING_UUENCODE, }, { "application/mac-binhex40", CAMEL_TRANSFER_ENCODING_7BIT, }, { "application/postscript", CAMEL_TRANSFER_ENCODING_7BIT, }, - { "text/plain", CAMEL_TRANSFER_ENCODING_7BIT, 1, }, + { "application/x-inlinepgp-signed", CAMEL_TRANSFER_ENCODING_DEFAULT, }, + { "application/x-inlinepgp-encrypted", CAMEL_TRANSFER_ENCODING_DEFAULT, }, }; static void @@ -124,12 +126,16 @@ emif_add_part(EMInlineFilter *emif, const char *data, int len) CamelMimePart *part; const char *mimetype; - if (emif->state == EMIF_PLAIN) + if (emif->state == EMIF_PLAIN || emif->state == EMIF_PGPSIGNED || emif->state == EMIF_PGPENCRYPTED) type = emif->base_encoding; else type = emif_types[emif->state].type; g_byte_array_append(emif->data, data, len); + /* check the part will actually have content */ + if (emif->data->len <= 0) { + return; + } mem = camel_stream_mem_new_with_byte_array(emif->data); emif->data = g_byte_array_new(); @@ -223,17 +229,18 @@ emif_scan(CamelMimeFilter *f, char *in, size_t len, int final) emif_add_part(emif, data_start, start-data_start); data_start = start; emif->state = EMIF_POSTSCRIPT; -#if 0 -/* This should be hooked in once someone can work out how to handle it. - Maybe we need a multipart_gpg_inline_signed or some crap, if it - can't be converted to a real multipart/signed */ } else if (strncmp(start, "-----BEGIN PGP SIGNED MESSAGE-----", 34) == 0) { inptr[-1] = '\n'; emif_add_part(emif, data_start, start-data_start); data_start = start; emif->state = EMIF_PGPSIGNED; -#endif + } else if (strncmp(start, "-----BEGIN PGP MESSAGE-----", 27) == 0) { + inptr[-1] = '\n'; + emif_add_part(emif, data_start, start-data_start); + data_start = start; + emif->state = EMIF_PGPENCRYPTED; } + break; case EMIF_UUENC: if (strcmp(start, "end") == 0) { @@ -279,7 +286,6 @@ emif_scan(CamelMimeFilter *f, char *in, size_t len, int final) } break; case EMIF_PGPSIGNED: - /* This is currently a noop - it just turns it into a text part */ if (strcmp(start, "-----END PGP SIGNATURE-----") == 0) { inptr[-1] = '\n'; emif_add_part(emif, data_start, inptr-data_start); @@ -287,6 +293,14 @@ emif_scan(CamelMimeFilter *f, char *in, size_t len, int final) emif->state = EMIF_PLAIN; } break; + case EMIF_PGPENCRYPTED: + if (strcmp(start, "-----END PGP MESSAGE-----") == 0) { + inptr[-1] = '\n'; + emif_add_part(emif, data_start, inptr-data_start); + data_start = inptr; + emif->state = EMIF_PLAIN; + } + break; } inptr[-1] = '\n'; -- cgit v1.2.3