[evolution] Workaround broken GPG encrypted messages from Exchange and GroupWise servers
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Workaround broken GPG encrypted messages from Exchange and GroupWise servers
- Date: Thu, 27 Jul 2017 08:51:51 +0000 (UTC)
commit 4643f76e049c83a2562b1c17dcd3764eaeb7f08b
Author: Milan Crha <mcrha redhat com>
Date: Thu Jul 27 10:25:44 2017 +0200
Workaround broken GPG encrypted messages from Exchange and GroupWise servers
An Exchange server, eventually also a GroupWise server, can break a GPG
encrypted message structure by changing it from
multipart/encrypted; protocol="application/pgp-encrypted"
application/pgp-encrypted
application/octet-stream; name="encrypted.asc"
to something like:
multipart/mixed
text/plain
application/pgp-encrypted; name="ATT00001"
application/octet-stream; name="encrypted.asc"
where the text/plain part is empty and is added by the Exchange server.
The added code tries to detect such issues and if recognized, then
changes the structure to be able to decrypt the message as expected.
src/em-format/e-mail-parser-multipart-mixed.c | 67 +++++++++++++++++++++++++
1 files changed, 67 insertions(+), 0 deletions(-)
---
diff --git a/src/em-format/e-mail-parser-multipart-mixed.c b/src/em-format/e-mail-parser-multipart-mixed.c
index 480cb12..cc6a023 100644
--- a/src/em-format/e-mail-parser-multipart-mixed.c
+++ b/src/em-format/e-mail-parser-multipart-mixed.c
@@ -50,6 +50,7 @@ empe_mp_mixed_parse (EMailParserExtension *extension,
GQueue *out_mail_parts)
{
CamelMultipart *mp;
+ CamelMimePart *pgp_encrypted = NULL, *pgp_octet_stream = NULL;
gint i, nparts, len;
mp = (CamelMultipart *) camel_medium_get_content ((CamelMedium *) part);
@@ -62,6 +63,41 @@ empe_mp_mixed_parse (EMailParserExtension *extension,
len = part_id->len;
nparts = camel_multipart_get_number (mp);
+
+ if ((nparts == 2 || nparts == 3) &&
+ !g_str_has_suffix (part_id->str, ".mixed-as-pgp-encrypted")) {
+ for (i = 0; i < nparts; i++) {
+ CamelMimePart *subpart;
+ CamelContentType *ct;
+
+ subpart = camel_multipart_get_part (mp, i);
+ ct = camel_mime_part_get_content_type (subpart);
+
+ if (ct) {
+ if (camel_content_type_is (ct, "application", "pgp-encrypted")) {
+ if (pgp_encrypted) {
+ pgp_encrypted = NULL;
+ break;
+ }
+
+ pgp_encrypted = subpart;
+ } else if (camel_content_type_is (ct, "application", "octet-stream")) {
+ if (pgp_octet_stream) {
+ pgp_octet_stream = NULL;
+ break;
+ }
+
+ pgp_octet_stream = subpart;
+ }
+ }
+ }
+
+ if (!pgp_encrypted || !pgp_octet_stream) {
+ pgp_encrypted = NULL;
+ pgp_octet_stream = NULL;
+ }
+ }
+
for (i = 0; i < nparts; i++) {
GQueue work_queue = G_QUEUE_INIT;
EMailPart *mail_part;
@@ -71,6 +107,37 @@ empe_mp_mixed_parse (EMailParserExtension *extension,
subpart = camel_multipart_get_part (mp, i);
+ if (subpart == pgp_encrypted ||
+ subpart == pgp_octet_stream) {
+ /* Garbled PGP enctryped message by an Exchange server; show it
+ at the position, where the pgp-encrypted part is. */
+ if (subpart == pgp_encrypted &&
+ pgp_encrypted && pgp_octet_stream) {
+ CamelMultipart *encrypted;
+ CamelMimePart *tmp_part;
+
+ encrypted = CAMEL_MULTIPART (camel_multipart_encrypted_new ());
+ camel_data_wrapper_set_mime_type (CAMEL_DATA_WRAPPER (encrypted),
"multipart/encrypted; protocol=\"application/pgp-encrypted\"");
+ camel_multipart_add_part (encrypted, pgp_encrypted);
+ camel_multipart_add_part (encrypted, pgp_octet_stream);
+
+ tmp_part = camel_mime_part_new ();
+ camel_mime_part_set_content_type (tmp_part, "multipart/encrypted;
protocol=\"application/pgp-encrypted\"");
+ camel_medium_set_content (CAMEL_MEDIUM (tmp_part), CAMEL_DATA_WRAPPER
(encrypted));
+
+ g_string_append (part_id, ".mixed-as-pgp-encrypted");
+
+ e_mail_parser_parse_part_as (parser, tmp_part, part_id,
+ "multipart/encrypted", cancellable, out_mail_parts);
+
+ g_string_truncate (part_id, len);
+
+ g_object_unref (tmp_part);
+ g_object_unref (encrypted);
+ }
+ continue;
+ }
+
g_string_append_printf (part_id, ".mixed.%d", i);
handled = e_mail_parser_parse_part (
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]