]> source.dussan.org Git - rspamd.git/commitdiff
* Add debug for mime parsing
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Sun, 1 Mar 2009 22:39:40 +0000 (01:39 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Sun, 1 Mar 2009 22:39:40 +0000 (01:39 +0300)
* Fill task structure with zeroes in url-extracter

src/message.c
src/protocol.c
utils/url_extracter.c

index d5ec43653782cfee9df8f03370a33e4431dbb219..9499a343be526d9ae2f160e17ee3a93f7abcc7c9 100644 (file)
@@ -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 ();
index 28b9b8251840f02b6291432e2ec76549d5ed5b7b..9999dc27997680a16c6d26228fe1c763967f62a4 100644 (file)
@@ -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;
                }
index 9d5fa1241f57f8cf95708f360254da8bdb9077a5..75dd5c1d3666a157a1c4886fe439bddc685f8153 100644 (file)
@@ -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);