Do not try to handle quotes in text attachments.
[claws.git] / src / textview.c
index 1ecaebc33da6b2e0c99eaf50c560f8ae4b8f38a7..c9be5d8ad058810c328b1defdd202d3690ee9716 100644 (file)
@@ -1074,6 +1074,7 @@ static void textview_write_body(TextView *textview, MimeInfo *mimeinfo)
        
        textview->is_in_signature = FALSE;
        textview->is_diff = FALSE;
+       textview->is_attachment = FALSE;;
 
        procmime_decode_content(mimeinfo);
 
@@ -1174,6 +1175,13 @@ textview_default:
                                || !g_ascii_strcasecmp(mimeinfo->subtype, "x-diff"))
                        textview->is_diff = TRUE;
 
+               /* Displayed part is an attachment, but not an attached
+                * e-mail. Set a flag, so that elsewhere in the code we
+                * know not to try making collapsible quotes in it. */
+               if (mimeinfo->disposition == DISPOSITIONTYPE_ATTACHMENT &&
+                               mimeinfo->type != MIMETYPE_MESSAGE)
+                       textview->is_attachment = TRUE;
+
                if (mimeinfo->content == MIMECONTENT_MEM)
                        tmpfp = str_open_as_stream(mimeinfo->data.mem);
                else
@@ -1597,7 +1605,8 @@ static void textview_write_line(TextView *textview, const gchar *str,
           >, foo>, _> ... ok, <foo>, foo bar>, foo-> ... ng
           Up to 3 levels of quotations are detected, and each
           level is colored using a different color. */
-       if (prefs_common.enable_color 
+       if (prefs_common.enable_color
+           && !textview->is_attachment
            && line_has_quote_char(buf, prefs_common.quote_chars)) {
                real_quotelevel = get_quote_level(buf, prefs_common.quote_chars);
                quotelevel = real_quotelevel;
@@ -1640,7 +1649,7 @@ static void textview_write_line(TextView *textview, const gchar *str,
                }
        }
 
-       if (real_quotelevel > -1 && do_quote_folding) {
+       if (!textview->is_attachment && real_quotelevel > -1 && do_quote_folding) {
                if (!g_utf8_validate(buf, -1, NULL)) {
                        gchar *utf8buf = NULL;
                        utf8buf = g_malloc(BUFFSIZE);
@@ -2706,7 +2715,7 @@ static void textview_toggle_quote(TextView *textview, GSList *start_list, Clicka
                gtk_text_buffer_get_iter_at_offset(buffer, &start, uri->start);
                gtk_text_buffer_insert_with_tags_by_name
                                (buffer, &start, (gchar *)uri->data, 
-                                uri->data_len,
+                                strlen((gchar *)uri->data)-1,
                                 "qlink", (gchar *)uri->fg_color, NULL);
                uri->end = gtk_text_iter_get_offset(&start);
                textview_make_clickable_parts_later(textview,