[evolution-data-server] M!17 - Use Media Type from RFC 8551 for S/MIME creation



commit 0f072ebb9a33321690c5be5bb6352287539b971a
Author: Tom Kranz <TpmKranz users noreply github com>
Date:   Thu Jun 6 15:36:45 2019 +0200

    M!17 - Use Media Type from RFC 8551 for S/MIME creation
    
    Closes https://gitlab.gnome.org/GNOME/evolution-data-server/merge_requests/17

 src/camel/camel-folder-summary.c |  8 ++++++--
 src/camel/camel-mime-utils.c     |  7 ++++---
 src/camel/camel-smime-context.c  | 30 ++++++++++++++++++++----------
 3 files changed, 30 insertions(+), 15 deletions(-)
---
diff --git a/src/camel/camel-folder-summary.c b/src/camel/camel-folder-summary.c
index 5b83955da..10c7caff0 100644
--- a/src/camel/camel-folder-summary.c
+++ b/src/camel/camel-folder-summary.c
@@ -3122,8 +3122,10 @@ summary_traverse_content_with_parser (CamelFolderSummary *summary,
                /* update attachments flag as we go */
                if (camel_content_type_is (ct, "application", "pgp-signature")
 #ifdef ENABLE_SMIME
-                   || camel_content_type_is (ct, "application", "x-pkcs7-signature")
                    || camel_content_type_is (ct, "application", "pkcs7-signature")
+                   || camel_content_type_is (ct, "application", "xpkcs7signature")
+                   || camel_content_type_is (ct, "application", "xpkcs7-signature")
+                   || camel_content_type_is (ct, "application", "x-pkcs7-signature")
 #endif
                        )
                        camel_message_info_set_flags (msginfo, CAMEL_MESSAGE_SECURE, CAMEL_MESSAGE_SECURE);
@@ -3282,8 +3284,10 @@ summary_traverse_content_with_part (CamelFolderSummary *summary,
                        camel_message_info_set_flags (msginfo, CAMEL_MESSAGE_SECURE, CAMEL_MESSAGE_SECURE);
        } else if (camel_content_type_is (ct, "application", "pgp-signature")
 #ifdef ENABLE_SMIME
-                   || camel_content_type_is (ct, "application", "x-pkcs7-signature")
                    || camel_content_type_is (ct, "application", "pkcs7-signature")
+                   || camel_content_type_is (ct, "application", "xpkcs7signature")
+                   || camel_content_type_is (ct, "application", "xpkcs7-signature")
+                   || camel_content_type_is (ct, "application", "x-pkcs7-signature")
 #endif
                ) {
                camel_message_info_set_flags (msginfo, CAMEL_MESSAGE_SECURE, CAMEL_MESSAGE_SECURE);
diff --git a/src/camel/camel-mime-utils.c b/src/camel/camel-mime-utils.c
index a10377e22..c742fb762 100644
--- a/src/camel/camel-mime-utils.c
+++ b/src/camel/camel-mime-utils.c
@@ -3910,9 +3910,10 @@ camel_content_disposition_is_attachment_ex (const CamelContentDisposition *dispo
                                            const CamelContentType *parent_content_type)
 {
        if (content_type && (
+           camel_content_type_is (content_type, "application", "pkcs7-mime") ||
            camel_content_type_is (content_type, "application", "xpkcs7mime") ||
-           camel_content_type_is (content_type, "application", "x-pkcs7-mime") ||
-           camel_content_type_is (content_type, "application", "pkcs7-mime")))
+           camel_content_type_is (content_type, "application", "xpkcs7-mime") ||
+           camel_content_type_is (content_type, "application", "x-pkcs7-mime")))
                return FALSE;
 
        if (content_type && (
@@ -3925,9 +3926,9 @@ camel_content_disposition_is_attachment_ex (const CamelContentDisposition *dispo
 
        if (content_type && (
            camel_content_type_is (content_type, "application", "pkcs7-signature") ||
+           camel_content_type_is (content_type, "application", "xpkcs7signature") ||
            camel_content_type_is (content_type, "application", "xpkcs7-signature") ||
            camel_content_type_is (content_type, "application", "x-pkcs7-signature") ||
-           camel_content_type_is (content_type, "application", "pkcs7-signature") ||
            camel_content_type_is (content_type, "application", "pgp-signature")))
                return !parent_content_type || !camel_content_type_is (parent_content_type, "multipart", 
"signed");
 
diff --git a/src/camel/camel-smime-context.c b/src/camel/camel-smime-context.c
index 214eaa430..e6aa7a10b 100644
--- a/src/camel/camel-smime-context.c
+++ b/src/camel/camel-smime-context.c
@@ -910,7 +910,7 @@ smime_context_sign_sync (CamelCipherContext *context,
                CamelMimePart *sigpart;
 
                sigpart = camel_mime_part_new ();
-               ct = camel_content_type_new ("application", "x-pkcs7-signature");
+               ct = camel_content_type_new ("application", "pkcs7-signature");
                camel_content_type_set_param (ct, "name", "smime.p7s");
                camel_data_wrapper_set_mime_type_field (dw, ct);
                camel_content_type_unref (ct);
@@ -940,7 +940,7 @@ smime_context_sign_sync (CamelCipherContext *context,
 
                camel_medium_set_content ((CamelMedium *) opart, (CamelDataWrapper *) mps);
        } else {
-               ct = camel_content_type_new ("application", "x-pkcs7-mime");
+               ct = camel_content_type_new ("application", "pkcs7-mime");
                camel_content_type_set_param (ct, "name", "smime.p7m");
                camel_content_type_set_param (ct, "smime-type", "signed-data");
                camel_data_wrapper_set_mime_type_field (dw, ct);
@@ -996,7 +996,9 @@ smime_context_verify_sync (CamelCipherContext *context,
                if (!CAMEL_IS_MULTIPART_SIGNED (mps)
                    || tmp == NULL
                    || (g_ascii_strcasecmp (tmp, class->sign_protocol) != 0
-                       && g_ascii_strcasecmp (tmp, "application/pkcs7-signature") != 0)) {
+                       && g_ascii_strcasecmp (tmp, "application/xpkcs7signature") != 0
+                       && g_ascii_strcasecmp (tmp, "application/xpkcs7-signature") != 0
+                       && g_ascii_strcasecmp (tmp, "application/x-pkcs7-signature") != 0)) {
                        g_set_error (
                                error, CAMEL_ERROR, CAMEL_ERROR_GENERIC,
                                _("Cannot verify message signature: "
@@ -1017,7 +1019,10 @@ smime_context_verify_sync (CamelCipherContext *context,
                                "Incorrect message format"));
                        goto fail;
                }
-       } else if (camel_content_type_is (ct, "application", "x-pkcs7-mime")) {
+       } else if (camel_content_type_is (ct, "application", "pkcs7-mime")
+                  || camel_content_type_is (ct, "application", "xpkcs7mime")
+                  || camel_content_type_is (ct, "application", "xpkcs7-mime")
+                  || camel_content_type_is (ct, "application", "x-pkcs7-mime")) {
                sigpart = ipart;
        } else {
                g_set_error (
@@ -1434,7 +1439,7 @@ smime_context_encrypt_sync (CamelCipherContext *context,
        g_object_unref (ostream);
        camel_data_wrapper_set_encoding (dw, CAMEL_TRANSFER_ENCODING_BINARY);
 
-       ct = camel_content_type_new ("application", "x-pkcs7-mime");
+       ct = camel_content_type_new ("application", "pkcs7-mime");
        camel_content_type_set_param (ct, "name", "smime.p7m");
        camel_content_type_set_param (ct, "smime-type", "enveloped-data");
        camel_data_wrapper_set_mime_type_field (dw, ct);
@@ -1573,9 +1578,9 @@ camel_smime_context_class_init (CamelSMIMEContextClass *class)
        g_type_class_add_private (class, sizeof (CamelSMIMEContextPrivate));
 
        cipher_context_class = CAMEL_CIPHER_CONTEXT_CLASS (class);
-       cipher_context_class->sign_protocol = "application/x-pkcs7-signature";
-       cipher_context_class->encrypt_protocol = "application/x-pkcs7-mime";
-       cipher_context_class->key_protocol = "application/x-pkcs7-signature";
+       cipher_context_class->sign_protocol = "application/pkcs7-signature";
+       cipher_context_class->encrypt_protocol = "application/pkcs7-mime";
+       cipher_context_class->key_protocol = "application/pkcs7-signature";
        cipher_context_class->hash_to_id = smime_context_hash_to_id;
        cipher_context_class->id_to_hash = smime_context_id_to_hash;
        cipher_context_class->sign_sync = smime_context_sign_sync;
@@ -1653,9 +1658,14 @@ camel_smime_context_describe_part (CamelSMIMEContext *context,
                tmp = camel_content_type_param (ct, "protocol");
                if (tmp &&
                    (g_ascii_strcasecmp (tmp, class->sign_protocol) == 0
-                    || g_ascii_strcasecmp (tmp, "application/pkcs7-signature") == 0))
+                    || g_ascii_strcasecmp (tmp, "application/xpkcs7signature") == 0
+                    || g_ascii_strcasecmp (tmp, "application/xpkcs7-signature") == 0
+                    || g_ascii_strcasecmp (tmp, "application/x-pkcs7-signature") == 0))
                        flags = CAMEL_SMIME_SIGNED;
-       } else if (camel_content_type_is (ct, "application", "x-pkcs7-mime")) {
+       } else if (camel_content_type_is (ct, "application", "pkcs7-mime")
+                  || camel_content_type_is (ct, "application", "xpkcs7mime")
+                  || camel_content_type_is (ct, "application", "xpkcs7-mime")
+                  || camel_content_type_is (ct, "application", "x-pkcs7-mime")) {
                CamelStream *istream;
                NSSCMSMessage *cmsg;
                NSSCMSDecoderContext *dec;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]