* src/modest-tny-msg.c:
authorJose Dapena Paz <jdapena@igalia.com>
Thu, 24 Apr 2008 15:49:46 +0000 (15:49 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Thu, 24 Apr 2008 15:49:46 +0000 (15:49 +0000)
* (modest_tny_msg_find_body_part_from_mime_part): if body is in
  the top mime part, lowcase before matching the content type so
  that content types like "TEXT/plain" match properly
  (fixes NB#84604).

pmo-trunk-r4461

src/modest-tny-msg.c

index b7c761d..de2d72c 100644 (file)
@@ -442,11 +442,20 @@ modest_tny_msg_find_body_part_from_mime_part (TnyMimePart *msg, gboolean want_ht
 
        /* no parts? assume it's single-part message */
        if (tny_iterator_is_done(iter)) {
-               const gchar *content_type;
+               gchar *content_type;
+               gchar *content_type_lower;
+               gboolean is_text_part;
                g_object_unref (G_OBJECT(iter));
-               content_type = tny_mime_part_get_content_type (msg);
+               content_type = g_strdup (tny_mime_part_get_content_type (msg));
+               if (content_type == NULL)
+                       return NULL;
+               content_type = g_strstrip (content_type);
+               content_type_lower = g_ascii_strdown (content_type, -1);
+               g_free (content_type);
+               is_text_part = g_str_has_prefix (content_type_lower, "text/");
+               g_free (content_type_lower);
                /* if this part cannot be a supported body return NULL */
-               if (!g_str_has_prefix (content_type, "text/")) {
+               if (!is_text_part) {
                        return NULL;
                } else {
                        return TNY_MIME_PART (g_object_ref(G_OBJECT(msg)));