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



commit 90926ae40501752160abba75cbc9ae819138dc47
Author: Milan Crha <mcrha redhat com>
Date:   Thu Jun 6 15:38:29 2019 +0200

    eds-M!17 - Use Media Type from RFC 8551 for S/MIME creation
    
    Make consistent list of recognized S/MIME MIME types with
    the list used in the merge request.
    
    Related to https://gitlab.gnome.org/GNOME/evolution-data-server/merge_requests/17

 src/composer/e-msg-composer.c                   | 17 ++++++++++++-----
 src/em-format/e-mail-parser-application-smime.c |  3 +++
 src/em-format/e-mail-parser-multipart-signed.c  |  6 ++++--
 src/em-format/e-mail-part-utils.c               |  4 ++++
 4 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/src/composer/e-msg-composer.c b/src/composer/e-msg-composer.c
index 6128c32724..e4c9ac095e 100644
--- a/src/composer/e-msg-composer.c
+++ b/src/composer/e-msg-composer.c
@@ -3260,7 +3260,10 @@ handle_multipart_signed (EMsgComposer *composer,
                if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (ACTION (SMIME_SIGN))) &&
                    !gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (ACTION (SMIME_ENCRYPT))))
                        action = GTK_TOGGLE_ACTION (ACTION (PGP_SIGN));
-       } else if (g_ascii_strcasecmp (protocol, "application/x-pkcs7-signature") == 0) {
+       } else if (g_ascii_strcasecmp (protocol, "application/pkcs7-signature") == 0 ||
+                  g_ascii_strcasecmp (protocol, "application/xpkcs7signature") == 0 ||
+                  g_ascii_strcasecmp (protocol, "application/xpkcs7-signature") == 0 ||
+                  g_ascii_strcasecmp (protocol, "application/x-pkcs7-signature") == 0) {
                if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (ACTION (PGP_SIGN))) &&
                    !gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (ACTION (PGP_ENCRYPT))))
                        action = GTK_TOGGLE_ACTION (ACTION (SMIME_SIGN));
@@ -3349,8 +3352,10 @@ handle_multipart_encrypted (EMsgComposer *composer,
                    !gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (ACTION (SMIME_ENCRYPT))))
                        action = GTK_TOGGLE_ACTION (ACTION (PGP_ENCRYPT));
        } else if (content_type && (
-                   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", "pkcs7-mime") ||
+                  camel_content_type_is (content_type, "application", "xpkcs7mime") ||
+                  camel_content_type_is (content_type, "application", "xpkcs7-mime") ||
+                  camel_content_type_is (content_type, "application", "x-pkcs7-mime"))) {
                if (!gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (ACTION (PGP_SIGN))) &&
                    !gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (ACTION (PGP_ENCRYPT))))
                        action = GTK_TOGGLE_ACTION (ACTION (SMIME_ENCRYPT));
@@ -4037,8 +4042,10 @@ e_msg_composer_setup_with_message (EMsgComposer *composer,
                is_html = camel_content_type_is (content_type, "text", "html");
 
                if (content_type != NULL && (
-                   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", "pkcs7-mime") ||
+                   camel_content_type_is (content_type, "application", "xpkcs7mime") ||
+                   camel_content_type_is (content_type, "application", "xpkcs7-mime") ||
+                   camel_content_type_is (content_type, "application", "x-pkcs7-mime"))) {
                        #ifdef ENABLE_SMIME
                        gtk_toggle_action_set_active (
                                GTK_TOGGLE_ACTION (
diff --git a/src/em-format/e-mail-parser-application-smime.c b/src/em-format/e-mail-parser-application-smime.c
index 47f8be798c..ae8f07763e 100644
--- a/src/em-format/e-mail-parser-application-smime.c
+++ b/src/em-format/e-mail-parser-application-smime.c
@@ -38,9 +38,11 @@ G_DEFINE_TYPE (
 
 static const gchar *parser_mime_types[] = {
        "application/xpkcs7mime",
+       "application/xpkcs7-mime",
        "application/x-pkcs7-mime",
        "application/pkcs7-mime",
        "application/pkcs7-signature",
+       "application/xpkcs7signature",
        "application/xpkcs7-signature",
        "application/x-pkcs7-signature",
        NULL
@@ -62,6 +64,7 @@ empe_app_smime_parse (EMailParserExtension *extension,
 
        ct = camel_mime_part_get_content_type (part);
        if (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")) {
                EMailPartList *part_list;
diff --git a/src/em-format/e-mail-parser-multipart-signed.c b/src/em-format/e-mail-parser-multipart-signed.c
index 4629c09f6b..c122d3ed28 100644
--- a/src/em-format/e-mail-parser-multipart-signed.c
+++ b/src/em-format/e-mail-parser-multipart-signed.c
@@ -117,8 +117,10 @@ empe_mp_signed_parse (EMailParserExtension *extension,
        /* FIXME: duplicated in em-format-html-display.c */
        if (protocol != NULL) {
 #ifdef ENABLE_SMIME
-               if (g_ascii_strcasecmp ("application/x-pkcs7-signature", protocol) == 0
-                   || g_ascii_strcasecmp ("application/pkcs7-signature", protocol) == 0) {
+               if (g_ascii_strcasecmp ("application/pkcs7-signature", protocol) == 0 ||
+                   g_ascii_strcasecmp ("application/xpkcs7signature", protocol) == 0 ||
+                   g_ascii_strcasecmp ("application/xpkcs7-signature", protocol) == 0 ||
+                   g_ascii_strcasecmp ("application/x-pkcs7-signature", protocol) == 0) {
                        cipher = camel_smime_context_new (session);
                        validity_type = E_MAIL_PART_VALIDITY_SMIME;
                } else {
diff --git a/src/em-format/e-mail-part-utils.c b/src/em-format/e-mail-part-utils.c
index 588b65afea..c43d25bf43 100644
--- a/src/em-format/e-mail-part-utils.c
+++ b/src/em-format/e-mail-part-utils.c
@@ -48,6 +48,8 @@ e_mail_part_is_secured (CamelMimePart *part)
                camel_content_type_is (ct, "multipart", "encrypted") ||
                camel_content_type_is (ct, "application", "x-inlinepgp-signed") ||
                camel_content_type_is (ct, "application", "x-inlinepgp-encrypted") ||
+               camel_content_type_is (ct, "application", "xpkcs7mime") ||
+               camel_content_type_is (ct, "application", "xpkcs7-mime") ||
                camel_content_type_is (ct, "application", "x-pkcs7-mime") ||
                camel_content_type_is (ct, "application", "pkcs7-mime"));
 }
@@ -294,6 +296,8 @@ e_mail_part_is_attachment (CamelMimePart *part)
 
        d (printf ("checking is attachment %s/%s\n", mime_type->type, mime_type->subtype));
        return !(camel_content_type_is (mime_type, "multipart", "*")
+                || camel_content_type_is (mime_type, "application", "xpkcs7mime")
+                || camel_content_type_is (mime_type, "application", "xpkcs7-mime")
                 || camel_content_type_is (mime_type, "application", "x-pkcs7-mime")
                 || camel_content_type_is (mime_type, "application", "pkcs7-mime")
                 || camel_content_type_is (mime_type, "application", "x-inlinepgp-signed")


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