[Commits] [SCM] claws branch, master, updated. 3.9.2-97-gd07722d

mones at claws-mail.org mones at claws-mail.org
Fri Oct 25 14:20:31 CEST 2013


The branch master of project "claws" (Claws Mail) has been updated
       via  d07722d7d00132463f5a86266c22140a69aa477a (commit)
      from  a16bc33909360086bb72908c3cc983e97ee9ebaa (commit)


- Log -----------------------------------------------------------------
commit d07722d7d00132463f5a86266c22140a69aa477a
Author: Ricardo Mones <ricardo at mones.org>
Date:   Fri Oct 25 14:09:00 2013 +0200

    Fix bug #2210, but not on Address Book
    
    Bug report is titled 'Display name with invalid addresses not quoted
    when inserted from address book', but the real problem is not the AB.
    
    AB doesn't care about the address format or validity, the problem is
    sending those addresses to the SMTP server, which, as seen in the wild¹,
    might care.
    
    Fix quotes all addresses which need quoting just before writting the
    message to the queue folder.
    
    ¹http://lists.claws-mail.org/pipermail/users/2013-October/007485.html

diff --git a/src/compose.c b/src/compose.c
index b5cec4f..1c8b05b 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -6129,6 +6129,44 @@ static int compose_add_attachments(Compose *compose, MimeInfo *parent)
 	return 0;
 }
 
+static gchar *compose_quote_list_of_addresses(gchar *str)
+{
+	GSList *list = NULL, *item = NULL;
+	gchar *qname = NULL, *faddr = NULL, *result = NULL;
+
+	list = address_list_append_with_comments(list, str);
+	for (item = list; item != NULL; item = item->next) {
+		gchar *spec = item->data;
+		gchar *endofname = strstr(spec, " <");
+		*endofname = '\0';
+		QUOTE_IF_REQUIRED_NORMAL(qname, spec, return NULL);
+		*endofname = ' ';
+		if (*qname != *spec) { /* has been quoted, compute new */
+			gchar *addr = g_strdup(endofname);
+			gchar *name = g_strdup(qname);
+			faddr = g_strconcat(name, addr, NULL);
+			g_free(name);
+			g_free(addr);
+			debug_print("new auto-quoted address: '%s'", faddr);
+		}
+		if (result == NULL)
+			result = g_strdup((faddr != NULL)? faddr: spec);
+		else {
+			result = g_strconcat(result,
+					     ", ",
+					     (faddr != NULL)? faddr: spec,
+					     NULL);
+		}
+		if (faddr != NULL) {
+			g_free(faddr);
+			faddr = NULL;
+		}
+	}
+	slist_free_strings_full(list);
+
+	return result;
+}
+
 #define IS_IN_CUSTOM_HEADER(header) \
 	(compose->account->add_customhdr && \
 	 custom_header_find(compose->account->customhdr_list, header) != NULL)
@@ -6161,9 +6199,11 @@ static void compose_add_headerfield_from_headerlist(Compose *compose,
 		headerentryname = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN((headerentry->combo)))));
 
 		if (!g_utf8_collate(trans_fieldname, headerentryname)) {
-			str = gtk_editable_get_chars(GTK_EDITABLE(headerentry->entry), 0, -1);
-			g_strstrip(str);
-			if (str[0] != '\0') {
+			gchar * ustr = gtk_editable_get_chars(GTK_EDITABLE(headerentry->entry), 0, -1);
+			g_strstrip(ustr);
+			str = compose_quote_list_of_addresses(ustr);
+			g_free(ustr);
+			if (str != NULL && str[0] != '\0') {
 				if (add_field)
 					g_string_append(fieldstr, seperator);
 				g_string_append(fieldstr, str);

-----------------------------------------------------------------------

Summary of changes:
 src/compose.c |   46 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 43 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list