From: Vsevolod Stakhov Date: Sun, 1 Mar 2009 22:39:40 +0000 (+0300) Subject: * Add debug for mime parsing X-Git-Tag: 0.2.7~291 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=de7c8a550a1bbc862c50187d66defcc87f0dece3;p=rspamd.git * Add debug for mime parsing * Fill task structure with zeroes in url-extracter --- diff --git a/src/message.c b/src/message.c index d5ec43653..9499a343b 100644 --- a/src/message.c +++ b/src/message.c @@ -274,23 +274,36 @@ mime_foreach_callback (GMimeObject *part, gpointer user_data) /* we'll get to finding out if this is a signed/encrypted multipart later... */ } else if (GMIME_IS_PART (part)) { /* a normal leaf part, could be text/plain or image/jpeg etc */ + type = (GMimeContentType *)g_mime_part_get_content_type (GMIME_PART (part)); + if (type == NULL) { + msg_warn ("mime_foreach_callback: type of part is unknown, assume text/plain"); + type = g_mime_content_type_new ("text", "plain"); + } wrapper = g_mime_part_get_content_object (GMIME_PART (part)); if (wrapper != NULL) { part_stream = g_mime_stream_mem_new (); if (g_mime_data_wrapper_write_to_stream (wrapper, part_stream) != -1) { part_content = g_mime_stream_mem_get_byte_array (GMIME_STREAM_MEM (part_stream)); - type = (GMimeContentType *)g_mime_part_get_content_type (GMIME_PART (part)); mime_part = memory_pool_alloc (task->task_pool, sizeof (struct mime_part)); mime_part->type = type; mime_part->content = part_content; + msg_debug ("mime_foreach_callback: found part with content-type: %s/%s", type->type, type->subtype); task->parts = g_list_prepend (task->parts, mime_part); if (g_mime_content_type_is_type (type, "text", "html")) { + msg_debug ("mime_foreach_callback: got urls from text/html part"); url_parse_html (task, part_content); } else if (g_mime_content_type_is_type (type, "text", "plain")) { url_parse_text (task, part_content); + msg_debug ("mime_foreach_callback: got urls from text/plain part"); } } + else { + msg_warn ("mime_foreach_callback: write to stream failed: %d, %m", errno); + } + } + else { + msg_warn ("mime_foreach_callback: cannot get wrapper for mime part, type of part: %s/%s", type->type, type->subtype); } } else { g_assert_not_reached (); diff --git a/src/protocol.c b/src/protocol.c index 28b9b8251..9999dc279 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -332,12 +332,14 @@ show_url_header (struct worker_task *task) if (TAILQ_NEXT (url, next) != NULL) { c = *(host.begin + host.len); *(host.begin + host.len) = '\0'; + msg_debug ("show_url_header: write url: %s", host.begin); r += snprintf (outbuf + r, sizeof (outbuf) - r, "%s, ", host.begin); *(host.begin + host.len) = c; } else { c = *(host.begin + host.len); *(host.begin + host.len) = '\0'; + msg_debug ("show_url_header: write url: %s", host.begin); r += snprintf (outbuf + r, sizeof (outbuf) - r, "%s" CRLF, host.begin); *(host.begin + host.len) = c; } diff --git a/utils/url_extracter.c b/utils/url_extracter.c index 9d5fa1241..75dd5c1d3 100644 --- a/utils/url_extracter.c +++ b/utils/url_extracter.c @@ -110,6 +110,7 @@ main (int argc, char **argv) g_mem_set_vtable(glib_mem_profiler_table); g_mime_init (0); + bzero (&task, sizeof (struct worker_task)); /* Preallocate buffer */ buf = g_malloc (size);