fix bug 4167, 'Max line length exceeded when forwarding mail'
[claws.git] / src / compose.c
index 487ec1c984c98b3b9e90611240eedfd1d7d08108..3657a113fbe85653d0f00e7534f7105f9f7bb70a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2018 the Claws Mail team and Hiroyuki Yamamoto
+ * Copyright (C) 1999-2019 the Claws Mail team and Hiroyuki Yamamoto
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -4256,10 +4256,16 @@ static gboolean compose_get_line_break_pos(GtkTextBuffer *buffer,
 
        for (; *p != '\0' && i < len; i++) {
                PangoLogAttr *attr = attrs + i;
-               gunichar wc;
+               gunichar wc = g_utf8_get_char(p);
                gint uri_len;
 
-               if (attr->is_line_break && can_break && was_white && !prev_dont_break)
+               /* attr->is_line_break will be false for some characters that
+                * we want to break a line before, like '/' or ':', so we
+                * also allow breaking on any non-wide character. The
+                * mentioned pango attribute is still useful to decide on
+                * line breaks when wide characters are involved. */
+               if ((!g_unichar_iswide(wc) || attr->is_line_break)
+                               && can_break && was_white && !prev_dont_break)
                        pos = i;
                
                was_white = attr->is_white;
@@ -4277,7 +4283,6 @@ static gboolean compose_get_line_break_pos(GtkTextBuffer *buffer,
                        continue;
                }
 
-               wc = g_utf8_get_char(p);
                if (g_unichar_iswide(wc)) {
                        col += 2;
                        if (prev_dont_break && can_break && attr->is_line_break)
@@ -4331,7 +4336,7 @@ static gboolean compose_join_next_line(Compose *compose,
        next_quote_str = compose_get_quote_str(buffer, &iter_, &quote_len);
 
        if ((quote_str || next_quote_str) &&
-           strcmp2(quote_str, next_quote_str) != 0) {
+           g_strcmp0(quote_str, next_quote_str) != 0) {
                g_free(next_quote_str);
                return FALSE;
        }
@@ -6453,7 +6458,7 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent)
                }
                if (ainfo->name && mimepart->type != MIMETYPE_MESSAGE) {
                        if (mimepart->type == MIMETYPE_APPLICATION && 
-                          !strcmp2(mimepart->subtype, "octet-stream"))
+                          !g_strcmp0(mimepart->subtype, "octet-stream"))
                                g_hash_table_insert(mimepart->typeparameters,
                                                g_strdup("name"), g_strdup(ainfo->name));
                        g_hash_table_insert(mimepart->dispositionparameters,
@@ -6464,7 +6469,7 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent)
                if (mimepart->type == MIMETYPE_MESSAGE
                    || mimepart->type == MIMETYPE_MULTIPART)
                        ainfo->encoding = ENC_BINARY;
-               else if (compose->use_signing) {
+               else if (compose->use_signing || compose->fwdinfo != NULL) {
                        if (ainfo->encoding == ENC_7BIT)
                                ainfo->encoding = ENC_QUOTED_PRINTABLE;
                        else if (ainfo->encoding == ENC_8BIT)
@@ -7535,7 +7540,7 @@ static GtkWidget *compose_create_others(Compose *compose)
        g_signal_connect_after(G_OBJECT(savemsg_combo), "grab_focus",
                         G_CALLBACK(compose_grab_focus_cb), compose);
        if (account_get_special_folder(compose->account, F_OUTBOX)) {
-               if (compose->account->set_sent_folder)
+               if (compose->account->set_sent_folder || prefs_common.savemsg)
                        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(savemsg_checkbtn), TRUE);
                else
                        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(savemsg_checkbtn), FALSE);
@@ -9481,11 +9486,11 @@ static void compose_attach_property_create(gboolean *cancelled)
 
                tmp = g_strdup_printf("%s/%s", type->type, type->sub_type);
 
-               if (g_list_find_custom(strlist, tmp, (GCompareFunc)strcmp2))
+               if (g_list_find_custom(strlist, tmp, (GCompareFunc)g_strcmp0))
                        g_free(tmp);
                else
                        strlist = g_list_insert_sorted(strlist, (gpointer)tmp,
-                                       (GCompareFunc)strcmp2);
+                                       (GCompareFunc)g_strcmp0);
        }
 
        for (mime_type_list = strlist; mime_type_list != NULL; 
@@ -10145,7 +10150,7 @@ static void account_activated(GtkComboBox *optmenu, gpointer data)
                compose_set_save_to(compose, folderidentifier);
                g_free(folderidentifier);
        } else if (account_get_special_folder(compose->account, F_OUTBOX)) {
-               if (compose->account->set_sent_folder)
+               if (compose->account->set_sent_folder || prefs_common.savemsg)
                        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn), TRUE);
                else
                        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn), FALSE);