From c029edde2e3cf2d02124e415a882955dd8075e26 Mon Sep 17 00:00:00 2001 From: San Cho Date: Thu, 7 Jul 2016 16:49:55 +0900 Subject: [PATCH] attachment of airtel's mail was not shown [Problem] attachment of airtel's mail was not shown [Cause & Measure] Cause: mime format of airtel's mail was wrong. attachment part should be under "mixed" multipart, but it was in "releated" multipart. Measure: checking content disposition to classify attachment part. Change-Id: I6f4b950995f15afe368d3eecef946f12e207ec38 --- email-core/email-core-gmime.c | 100 +++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 46 deletions(-) diff --git a/email-core/email-core-gmime.c b/email-core/email-core-gmime.c index f16b8b8..cfb2494 100755 --- a/email-core/email-core-gmime.c +++ b/email-core/email-core-gmime.c @@ -509,18 +509,20 @@ static void emcore_gmime_pop3_parse_foreach_cb(GMimeObject *parent, GMimeObject /*Content - END*/ /*Figure out TEXT or ATTACHMENT(INLINE) ?*/ - if ((!disposition_str && g_ascii_strcasecmp(ctype_type, "text") == 0) && + if ((!disposition_str && ctype_type && g_ascii_strcasecmp(ctype_type, "text") == 0) && (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) { EM_DEBUG_LOG("TEXT"); - } else if (parent_ctype_subtype && + } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) || + (parent_ctype_subtype && g_ascii_strncasecmp(parent_ctype_subtype, "mixed", strlen("mixed")) == 0)) { + content_disposition_type = ATTACHMENT; + EM_DEBUG_LOG("ATTACHMENT"); + } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, "inline") == 0) || + (parent_ctype_subtype && ((g_ascii_strncasecmp(parent_ctype_subtype, "related", strlen("related")) == 0) || - (g_ascii_strncasecmp(parent_ctype_subtype, "relative", strlen("relative")) == 0))) { + (g_ascii_strncasecmp(parent_ctype_subtype, "relative", strlen("relative")) == 0)))) { content_disposition_type = INLINE_ATTACHMENT; EM_DEBUG_LOG("INLINE_ATTACHMENT"); - } else if (parent_ctype_subtype && g_ascii_strcasecmp(parent_ctype_subtype, "mixed") == 0) { - content_disposition_type = ATTACHMENT; - EM_DEBUG_LOG("ATTACHMENT"); } else { int result = false; if (content_id && (emcore_search_string_from_file(cnt_info->text.html, @@ -1093,17 +1095,18 @@ static void emcore_gmime_eml_parse_foreach_cb(GMimeObject *parent, GMimeObject * g_ascii_strcasecmp(ctype_subtype, "html") == 0)) { cnt_info->total_body_size += content_size; EM_DEBUG_LOG("TEXT"); - } else if (parent_ctype_subtype && + } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) || + (parent_ctype_subtype && g_ascii_strncasecmp(parent_ctype_subtype, "mixed", strlen("mixed")) == 0)) { + content_disposition_type = ATTACHMENT; + cnt_info->total_attachment_size += content_size; + EM_DEBUG_LOG("ATTACHMENT"); + } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, "inline") == 0) || + (parent_ctype_subtype && ((g_ascii_strncasecmp(parent_ctype_subtype, "related", strlen("related")) == 0) || - (g_ascii_strncasecmp(parent_ctype_subtype, "relative", strlen("relative")) == 0))) { + (g_ascii_strncasecmp(parent_ctype_subtype, "relative", strlen("relative")) == 0)))) { content_disposition_type = INLINE_ATTACHMENT; cnt_info->total_body_size += content_size; EM_DEBUG_LOG("INLINE_ATTACHMENT"); - } else if (parent_ctype_subtype && - g_ascii_strncasecmp(parent_ctype_subtype, "mixed", strlen("mixed")) == 0) { - content_disposition_type = ATTACHMENT; - cnt_info->total_attachment_size += content_size; - EM_DEBUG_LOG("ATTACHMENT"); } else { int result = false; if (content_id && (emcore_search_string_from_file(cnt_info->text.html, @@ -1519,15 +1522,16 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_foreach_cb(GMimeObject *parent, GMime (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) { EM_DEBUG_LOG("TEXT"); - } else if (parent_ctype_subtype && + } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) || + (parent_ctype_subtype && g_ascii_strncasecmp(parent_ctype_subtype, "mixed", strlen("mixed")) == 0)) { + content_disposition_type = ATTACHMENT; + EM_DEBUG_LOG("ATTACHMENT"); + } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, "inline") == 0) || + (parent_ctype_subtype && ((g_ascii_strncasecmp(parent_ctype_subtype, "related", strlen("related")) == 0) || - (g_ascii_strncasecmp(parent_ctype_subtype, "relative", strlen("relative")) == 0))) { + (g_ascii_strncasecmp(parent_ctype_subtype, "relative", strlen("relative")) == 0)))) { content_disposition_type = INLINE_ATTACHMENT; EM_DEBUG_LOG("INLINE_ATTACHMENT"); - } else if (parent_ctype_subtype && - g_ascii_strncasecmp(parent_ctype_subtype, "mixed", strlen("mixed")) == 0) { - content_disposition_type = ATTACHMENT; - EM_DEBUG_LOG("ATTACHMENT"); } else { int result = false; if (content_id && (emcore_search_string_from_file(cnt_info->text.html, @@ -1979,7 +1983,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent, parent_ctype = g_mime_object_get_content_type(parent); parent_ctype_type = (char *)g_mime_content_type_get_media_type(parent_ctype); parent_ctype_subtype = (char *)g_mime_content_type_get_media_subtype(parent_ctype); - EM_DEBUG_LOG("Content-type[%s/%s]", parent_ctype_type, parent_ctype_subtype); + EM_DEBUG_LOG("Parent Content-type[%s/%s]", parent_ctype_type, parent_ctype_subtype); /*Content Type*/ ctype = g_mime_object_get_content_type(mobject); @@ -2018,15 +2022,16 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_full_foreach_cb(GMimeObject *parent, (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) { EM_DEBUG_LOG("TEXT"); - } else if (parent_ctype_subtype && + } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) || + (parent_ctype_subtype && g_ascii_strncasecmp(parent_ctype_subtype, "mixed", strlen("mixed")) == 0)) { + content_disposition_type = ATTACHMENT; + EM_DEBUG_LOG("ATTACHMENT"); + } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, "inline") == 0) || + (parent_ctype_subtype && ((g_ascii_strncasecmp(parent_ctype_subtype, "related", strlen("related")) == 0) || - (g_ascii_strncasecmp(parent_ctype_subtype, "relative", strlen("relative")) == 0))) { + (g_ascii_strncasecmp(parent_ctype_subtype, "relative", strlen("relative")) == 0)))) { content_disposition_type = INLINE_ATTACHMENT; EM_DEBUG_LOG("INLINE_ATTACHMENT"); - } else if (parent_ctype_subtype && - g_ascii_strncasecmp(parent_ctype_subtype, "mixed", strlen("mixed")) == 0) { - content_disposition_type = ATTACHMENT; - EM_DEBUG_LOG("ATTACHMENT"); } else { int result = false; if (content_id && (emcore_search_string_from_file(cnt_info->text.html, @@ -2429,7 +2434,7 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_bodystructure_foreach_cb(GMimeObject parent_ctype = g_mime_object_get_content_type(parent); parent_ctype_type = (char *)g_mime_content_type_get_media_type(parent_ctype); parent_ctype_subtype = (char *)g_mime_content_type_get_media_subtype(parent_ctype); - EM_DEBUG_LOG("Content-type[%s/%s]", parent_ctype_type, parent_ctype_subtype); + EM_DEBUG_LOG("Parent Content-type[%s/%s]", parent_ctype_type, parent_ctype_subtype); /* Parent content type - END */ /*Content Type*/ @@ -2474,17 +2479,18 @@ INTERNAL_FUNC void emcore_gmime_imap_parse_bodystructure_foreach_cb(GMimeObject g_ascii_strcasecmp(ctype_subtype, "html") == 0)) { cnt_info->total_body_size += content_size; EM_DEBUG_LOG("TEXT"); - } else if (parent_ctype_subtype && + } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) || + (parent_ctype_subtype && g_ascii_strncasecmp(parent_ctype_subtype, "mixed", strlen("mixed")) == 0)) { + content_disposition_type = ATTACHMENT; + cnt_info->total_attachment_size += content_size; + EM_DEBUG_LOG("ATTACHMENT"); + } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, "inline") == 0) || + (parent_ctype_subtype && ((g_ascii_strncasecmp(parent_ctype_subtype, "related", strlen("related")) == 0) || - (g_ascii_strncasecmp(parent_ctype_subtype, "relative", strlen("relative")) == 0))) { + (g_ascii_strncasecmp(parent_ctype_subtype, "relative", strlen("relative")) == 0)))) { content_disposition_type = INLINE_ATTACHMENT; cnt_info->total_body_size += content_size; EM_DEBUG_LOG("INLINE_ATTACHMENT"); - } else if (parent_ctype_subtype && - g_ascii_strncasecmp(parent_ctype_subtype, "mixed", strlen("mixed")) == 0) { - content_disposition_type = ATTACHMENT; - cnt_info->total_attachment_size += content_size; - EM_DEBUG_LOG("ATTACHMENT"); } else { if (disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) { content_disposition_type = ATTACHMENT; @@ -2720,15 +2726,16 @@ INTERNAL_FUNC void emcore_gmime_get_body_sections_foreach_cb(GMimeObject *parent (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) { EM_DEBUG_LOG("TEXT"); - } else if (parent_ctype_subtype && + } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) || + (parent_ctype_subtype && g_ascii_strncasecmp(parent_ctype_subtype, "mixed", strlen("mixed")) == 0)) { + content_disposition_type = ATTACHMENT; + EM_DEBUG_LOG("ATTACHMENT"); + } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, "inline") == 0) || + (parent_ctype_subtype && ((g_ascii_strncasecmp(parent_ctype_subtype, "related", strlen("related")) == 0) || - (g_ascii_strncasecmp(parent_ctype_subtype, "relative", strlen("relative")) == 0))) { + (g_ascii_strncasecmp(parent_ctype_subtype, "relative", strlen("relative")) == 0)))) { content_disposition_type = INLINE_ATTACHMENT; EM_DEBUG_LOG("INLINE_ATTACHMENT"); - } else if (parent_ctype_subtype && - g_ascii_strncasecmp(parent_ctype_subtype, "mixed", strlen("mixed")) == 0) { - content_disposition_type = ATTACHMENT; - EM_DEBUG_LOG("ATTACHMENT"); } else { if (disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) { content_disposition_type = ATTACHMENT; @@ -2947,15 +2954,16 @@ INTERNAL_FUNC void emcore_gmime_get_attachment_section_foreach_cb(GMimeObject *p (g_ascii_strcasecmp(ctype_subtype, "plain") == 0 || g_ascii_strcasecmp(ctype_subtype, "html") == 0)) { EM_DEBUG_LOG("TEXT"); - } else if (parent_ctype_subtype && + } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) || + (parent_ctype_subtype && g_ascii_strncasecmp(parent_ctype_subtype, "mixed", strlen("mixed")) == 0)) { + content_disposition_type = ATTACHMENT; + EM_DEBUG_LOG("ATTACHMENT"); + } else if ((disposition_str && g_ascii_strcasecmp(disposition_str, "inline") == 0) || + (parent_ctype_subtype && ((g_ascii_strncasecmp(parent_ctype_subtype, "related", strlen("related")) == 0) || - (g_ascii_strncasecmp(parent_ctype_subtype, "relative", strlen("relative")) == 0))) { + (g_ascii_strncasecmp(parent_ctype_subtype, "relative", strlen("relative")) == 0)))) { content_disposition_type = INLINE_ATTACHMENT; EM_DEBUG_LOG("INLINE_ATTACHMENT"); - } else if (parent_ctype_subtype && - g_ascii_strncasecmp(parent_ctype_subtype, "mixed", strlen("mixed")) == 0) { - content_disposition_type = ATTACHMENT; - EM_DEBUG_LOG("ATTACHMENT"); } else { if (disposition_str && g_ascii_strcasecmp(disposition_str, GMIME_DISPOSITION_ATTACHMENT) == 0) { content_disposition_type = ATTACHMENT; -- 2.7.4