[Commits] [SCM] claws branch, gtk3, updated. 3.16.0-536-gcf0873c

ticho at claws-mail.org ticho at claws-mail.org
Thu Dec 20 00:48:06 CET 2018


The branch, gtk3 has been updated
       via  cf0873c955328e729829bd15add5eed6f6ba8e48 (commit)
       via  a80416ea21247f4f7082033bc22bf0540f7084e7 (commit)
       via  ca19994f71ef73670c76d5b9f768c9ee92ea09ae (commit)
       via  5afa8c2859595e7a618337b1448d43e509253610 (commit)
       via  e493fa7e932d10c03356d32ea51ace8b9e700430 (commit)
       via  b3f1cc12f98f399675c9d58e0b76525b34af2b12 (commit)
       via  85e51d737624dc20140bca28ce35e11456b97cba (commit)
       via  a2f80ff8b7ddd630c1f9ce675fc8d2742faa798a (commit)
       via  8a6bba660a93192b78978933928589ff8a1e9f75 (commit)
       via  b42968f69c8c870c4e4c586fb0025179cc649c3d (commit)
       via  bf3eb7fcf23e44fa1fdc7b320c5f4cee0233f3c2 (commit)
      from  dbc74f0725947cc93455a1fd00bb9fe485099b53 (commit)

Summary of changes:
 src/addr_compl.c                                   |   13 +-
 src/common/ssl_certificate.c                       |   16 +-
 src/common/tests/Makefile.am                       |    4 +
 .../utils_get_serverportfp_from_filename_test.c    |  155 ++++++++++++++++++++
 src/common/utils.c                                 |  131 +++++++++++++----
 src/common/utils.h                                 |   29 ++--
 src/compose.c                                      |    2 +-
 src/edittags.c                                     |   27 +++-
 src/plugins/mailmbox/mailimf_types_helper.c        |    2 +-
 src/prefs_common.c                                 |    5 +
 src/prefs_common.h                                 |    2 +
 src/ssl_manager.c                                  |  113 ++++++--------
 12 files changed, 364 insertions(+), 135 deletions(-)
 create mode 100644 src/common/tests/utils_get_serverportfp_from_filename_test.c


- Log -----------------------------------------------------------------
commit cf0873c955328e729829bd15add5eed6f6ba8e48
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Thu Dec 20 00:47:45 2018 +0100

    Remove pre-GTK3 code from addr_compl.c.

diff --git a/src/addr_compl.c b/src/addr_compl.c
index 82e17f3..a2cde0a 100644
--- a/src/addr_compl.c
+++ b/src/addr_compl.c
@@ -945,14 +945,9 @@ static void completion_window_advance_selection(GtkTreeView *list_view, gboolean
  */
 static void addrcompl_resize_window( CompletionWindow *cw ) {
 	GtkRequisition r;
-	gint x, y, width, height, depth;
+	gint x, y, width, height;
 
-	/* Get current geometry of window */
-#if !GTK_CHECK_VERSION(3, 0, 0)
-	gdk_window_get_geometry( gtk_widget_get_window( cw->window ), &x, &y, &width, &height, &depth );
-#else
 	gdk_window_get_geometry( gtk_widget_get_window( cw->window ), &x, &y, &width, &height );
-#endif
 
 	gtk_widget_queue_resize_no_redraw(cw->list_view);
 	gtk_widget_size_request( cw->list_view, &r );
@@ -1445,7 +1440,7 @@ static gboolean address_completion_complete_address_in_entry(GtkEntry *entry,
  */
 static void address_completion_create_completion_window( GtkEntry *entry_ )
 {
-	gint x, y, height, width, depth;
+	gint x, y, height, width;
 	GtkWidget *scroll, *list_view;
 	GtkRequisition r;
 	GtkWidget *window;
@@ -1475,11 +1470,7 @@ static void address_completion_create_completion_window( GtkEntry *entry_ )
 		GTK_SHADOW_OUT);
 	/* Use entry widget to create initial window */
 	gdkwin = gtk_widget_get_window(entry),
-#if !GTK_CHECK_VERSION(3, 0, 0)
-	gdk_window_get_geometry(gdkwin, &x, &y, &width, &height, &depth);
-#else
 	gdk_window_get_geometry(gdkwin, &x, &y, &width, &height);
-#endif
 	gdk_window_get_origin (gdkwin, &x, &y);
 	y += height;
 	gtk_window_move(GTK_WINDOW(window), x, y);

commit a80416ea21247f4f7082033bc22bf0540f7084e7
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Mon Dec 17 21:51:32 2018 +0100

    Add unit tests for get_serverportfp_from_filename().

diff --git a/src/common/tests/Makefile.am b/src/common/tests/Makefile.am
index 767f6de..cff88d3 100644
--- a/src/common/tests/Makefile.am
+++ b/src/common/tests/Makefile.am
@@ -30,6 +30,10 @@ TEST_PROGS += unmime_test
 unmime_test_SOURCES = unmime_test.c
 unmime_test_LDADD = $(common_ldadd) ../unmime.o ../quoted-printable.o ../utils.o ../file-utils.o ../codeconv.o
 
+TEST_PROGS += utils_get_serverportfp_from_filename_test
+utils_get_serverportfp_from_filename_test_SOURCES = utils_get_serverportfp_from_filename_test.c
+utils_get_serverportfp_from_filename_test_LDADD = $(common_ldadd) ../utils.o ../file-utils.o ../codeconv.o ../quoted-printable.o ../unmime.o
+
 TEST_PROGS += utils_get_uri_part_test
 utils_get_uri_part_test_SOURCES = utils_get_uri_part_test.c
 utils_get_uri_part_test_LDADD = $(common_ldadd) ../utils.o ../file-utils.o ../codeconv.o ../quoted-printable.o ../unmime.o
diff --git a/src/common/tests/utils_get_serverportfp_from_filename_test.c b/src/common/tests/utils_get_serverportfp_from_filename_test.c
new file mode 100644
index 0000000..746aa9f
--- /dev/null
+++ b/src/common/tests/utils_get_serverportfp_from_filename_test.c
@@ -0,0 +1,155 @@
+#include <stdio.h>
+#include <glib.h>
+
+#include "utils.h"
+
+#include "mock_prefs_common_get_use_shred.h"
+#include "mock_prefs_common_get_flush_metadata.h"
+
+struct td {
+	gchar *str;
+	gboolean ret;
+	gchar *assertmsg;
+	gchar *host;
+	gchar *port;
+	gchar *fp;
+};
+
+#define ASSERTMSG_NULLINPUT "*CRITICAL* 'str != NULL' failed*"
+#define ASSERTMSG_FAILED "*could not parse filename*"
+
+struct td td_null = {
+	NULL,
+	FALSE, ASSERTMSG_NULLINPUT,
+	NULL, NULL, NULL
+};
+struct td td_empty = {
+	"",
+	FALSE, ASSERTMSG_FAILED,
+	NULL, NULL, NULL
+};
+struct td td_suffixonly = {
+	".cert",
+	FALSE, ASSERTMSG_FAILED,
+	NULL, NULL, NULL
+};
+struct td td_hostonly = {
+	"foo.cert",
+	FALSE, ASSERTMSG_FAILED,
+	"foo", NULL, NULL
+};
+struct td td_short_nofp = {
+	"shorthost.10.cert",
+	TRUE, NULL,
+	"shorthost", "10", NULL
+};
+struct td td_short_fp = {
+	"shorthost.10.ab:cd:ef:gh.cert",
+	TRUE, NULL,
+	"shorthost", "10", "ab:cd:ef:gh"
+};
+struct td td_ip_nofp = {
+	"10.20.30.40.10.cert",
+	TRUE, NULL,
+	"10.20.30.40", "10", NULL
+};
+struct td td_ip_fp = {
+	"10.20.30.40.10.ab:cd:ef:gh.cert",
+	TRUE, NULL,
+	"10.20.30.40", "10", "ab:cd:ef:gh"
+};
+struct td td_long_nofp = {
+	"longer.host.name.10.cert",
+	TRUE, NULL,
+	"longer.host.name", "10", NULL
+};
+struct td td_long_fp = {
+	"longer.host.name.10.ab:cd:ef:gh.cert",
+	TRUE, NULL,
+	"longer.host.name", "10", "ab:cd:ef:gh"
+};
+struct td td_cert_starts_with_digits = {
+	"longer.host.name.10.20:cd:ef:gh.cert",
+	TRUE, NULL,
+	"longer.host.name", "10", "20:cd:ef:gh"
+};
+
+void
+test_utils_get_serverportfp_from_filename_nulloutput()
+{
+	if (!g_test_undefined())
+		return;
+
+	if (g_test_subprocess()) {
+		gboolean ret = get_serverportfp_from_filename("valid.host.10.ab:cd:ef:gh.cert",
+				NULL, NULL, NULL);
+		g_assert_true(ret);
+		return;
+	}
+
+	g_test_trap_subprocess(NULL, 0, 0);
+	g_test_trap_assert_failed();
+}
+
+void
+test_utils_get_serverportfp_from_filename(gconstpointer user_data)
+{
+	const struct td *data = (const struct td *)user_data;
+
+	if (!g_test_undefined())
+		return;
+
+	if (g_test_subprocess()) {
+		gchar *host, *port, *fp;
+		gboolean ret = get_serverportfp_from_filename(data->str, &host, &port, &fp);
+
+		g_assert_true(ret == data->ret);
+		g_assert_cmpstr(host, ==, data->host);
+		g_assert_cmpstr(port, ==, data->port);
+		g_assert_cmpstr(fp, ==, data->fp);
+		return;
+	}
+
+	g_test_trap_subprocess(NULL, 0, 0);
+
+	if (!data->ret && data->assertmsg != NULL) {
+		g_test_trap_assert_stderr(data->assertmsg);
+		g_test_trap_assert_failed();
+	} else {
+		g_test_trap_assert_passed();
+	}
+}
+
+int
+main(int argc, char *argv[])
+{
+	g_test_init(&argc, &argv, NULL);
+
+	g_test_add_func("/common/utils/get_serverportfp_from_filename/nulloutput",
+			test_utils_get_serverportfp_from_filename_nulloutput);
+
+	g_test_add_data_func("/common/utils/get_serverportfp_from_filename/null",
+			&td_null, test_utils_get_serverportfp_from_filename);
+	g_test_add_data_func("/common/utils/get_serverportfp_from_filename/empty",
+			&td_empty, test_utils_get_serverportfp_from_filename);
+	g_test_add_data_func("/common/utils/get_serverportfp_from_filename/suffixonly",
+			&td_suffixonly, test_utils_get_serverportfp_from_filename);
+	g_test_add_data_func("/common/utils/get_serverportfp_from_filename/hostonly",
+			&td_hostonly, test_utils_get_serverportfp_from_filename);
+	g_test_add_data_func("/common/utils/get_serverportfp_from_filename/short_nofp",
+			&td_short_nofp, test_utils_get_serverportfp_from_filename);
+	g_test_add_data_func("/common/utils/get_serverportfp_from_filename/short_fp",
+			&td_short_fp, test_utils_get_serverportfp_from_filename);
+	g_test_add_data_func("/common/utils/get_serverportfp_from_filename/ip_nofp",
+			&td_ip_nofp, test_utils_get_serverportfp_from_filename);
+	g_test_add_data_func("/common/utils/get_serverportfp_from_filename/ip_fp",
+			&td_ip_fp, test_utils_get_serverportfp_from_filename);
+	g_test_add_data_func("/common/utils/get_serverportfp_from_filename/long_nofp",
+			&td_long_nofp, test_utils_get_serverportfp_from_filename);
+	g_test_add_data_func("/common/utils/get_serverportfp_from_filename/long_fp",
+			&td_long_fp, test_utils_get_serverportfp_from_filename);
+	g_test_add_data_func("/common/utils/get_serverportfp_from_filename/cert_starts_with_digits",
+			&td_cert_starts_with_digits, test_utils_get_serverportfp_from_filename);
+
+	return g_test_run();
+}

commit ca19994f71ef73670c76d5b9f768c9ee92ea09ae
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Mon Dec 17 22:22:01 2018 +0100

    Allow empty output parameters in get_serverportfp_from_filename()

diff --git a/src/common/utils.c b/src/common/utils.c
index 2e646ba..a815c48 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -4652,17 +4652,27 @@ gboolean get_serverportfp_from_filename(const gchar *str, gchar **server, gchar
 		return FALSE;
 	}
 
-	*server = g_strndup(str, dotport_pos - str);
+	if (server != NULL)
+		*server = g_strndup(str, dotport_pos - str);
 	if (dotfp_pos) {
-		*port = g_strndup(dotport_pos + 1, dotfp_pos - dotport_pos - 1);
-		*fp = g_strndup(dotfp_pos + 1, dotcert_pos - dotfp_pos - 1);
+		if (port != NULL)
+			*port = g_strndup(dotport_pos + 1, dotfp_pos - dotport_pos - 1);
+		if (fp != NULL)
+			*fp = g_strndup(dotfp_pos + 1, dotcert_pos - dotfp_pos - 1);
 	} else {
-		*port = g_strndup(dotport_pos + 1, dotcert_pos - dotport_pos - 1);
-		*fp = NULL;
+		if (port != NULL)
+			*port = g_strndup(dotport_pos + 1, dotcert_pos - dotport_pos - 1);
+		if (fp != NULL)
+			*fp = NULL;
 	}
 
-	debug_print("filename='%s' => server='%s' port='%s' fp='%s'\n", str, *server, *port, *fp);
-	if (!*server || !*port)
+	debug_print("filename='%s' => server='%s' port='%s' fp='%s'\n",
+			str,
+			(server ? *server : "(n/a)"),
+			(port ? *port : "(n/a)"),
+			(fp ? *fp : "(n/a)"));
+
+	if (!(server && *server) || !(port && *port))
 		return FALSE;
 	else
 		return TRUE;

commit 5afa8c2859595e7a618337b1448d43e509253610
Author: wwp <subscript at free.fr>
Date:   Tue Dec 18 10:36:26 2018 +0100

    Remember the size of the SSL manager window.

diff --git a/src/prefs_common.c b/src/prefs_common.c
index 6f39d1f..61fcbeb 100644
--- a/src/prefs_common.c
+++ b/src/prefs_common.c
@@ -1057,6 +1057,11 @@ static PrefParam param[] = {
 	{"tagswin_height", "-1", &prefs_common.tagswin_height, P_INT,
 	 NULL, NULL, NULL},
 
+	{"sslmanwin_width", "486", &prefs_common.sslmanwin_width, P_INT,
+	 NULL, NULL, NULL},
+	{"sslmanwin_height", "-1", &prefs_common.sslmanwin_height, P_INT,
+	 NULL, NULL, NULL},
+
 	{"addressbookwin_width", "520", &prefs_common.addressbookwin_width, P_INT,
 	 NULL, NULL, NULL},
 	{"addressbookwin_height", "-1", &prefs_common.addressbookwin_height, P_INT,
diff --git a/src/prefs_common.h b/src/prefs_common.h
index 2804186..6f68d69 100644
--- a/src/prefs_common.h
+++ b/src/prefs_common.h
@@ -496,6 +496,8 @@ struct _PrefsCommon
 	gint actionsiodialog_height;
 	gint tagswin_width;
 	gint tagswin_height;
+	gint sslmanwin_width;
+	gint sslmanwin_height;
 	gint addressbookwin_width;
 	gint addressbookwin_height;
 	gint addressbookeditpersonwin_width;
diff --git a/src/ssl_manager.c b/src/ssl_manager.c
index f51ca33..0735b2d 100644
--- a/src/ssl_manager.c
+++ b/src/ssl_manager.c
@@ -166,6 +166,18 @@ static GtkWidget *ssl_manager_list_view_create	(void)
 	return GTK_WIDGET(list_view);
 }
 
+/*!
+ *\brief	Save Gtk object size to prefs dataset
+ */
+static void ssl_manager_size_allocate_cb(GtkWidget *widget,
+					 GtkAllocation *allocation)
+{
+	cm_return_if_fail(allocation != NULL);
+
+	prefs_common.sslmanwin_width = allocation->width;
+	prefs_common.sslmanwin_height = allocation->height;
+}
+
 void ssl_manager_create(void)
 {
 	GtkWidget *window;
@@ -176,6 +188,7 @@ void ssl_manager_create(void)
 	GtkWidget *view_btn;
 	GtkWidget *delete_btn;
 	GtkWidget *close_btn;
+	static GdkGeometry geometry;
 
 	window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "ssl_manager");
 	gtk_window_set_title (GTK_WINDOW(window),
@@ -186,6 +199,8 @@ void ssl_manager_create(void)
 	gtk_window_set_resizable(GTK_WINDOW (window), TRUE);
 	g_signal_connect(G_OBJECT(window), "delete_event",
 			 G_CALLBACK(ssl_manager_close_cb), NULL);
+	g_signal_connect(G_OBJECT(window), "size_allocate",
+			 G_CALLBACK(ssl_manager_size_allocate_cb), NULL);
 	g_signal_connect(G_OBJECT(window), "key_press_event",
 			 G_CALLBACK(key_pressed), NULL);
 	MANAGE_WINDOW_SIGNALS_CONNECT (window);
@@ -211,6 +226,7 @@ void ssl_manager_create(void)
 	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
 					GTK_POLICY_NEVER,
 					GTK_POLICY_AUTOMATIC);
+
 	gtk_container_add(GTK_CONTAINER (scroll), certlist);
 
 	gtk_box_pack_start(GTK_BOX(hbox1), scroll, TRUE, TRUE, 0);
@@ -219,6 +235,16 @@ void ssl_manager_create(void)
 	gtk_box_pack_start(GTK_BOX(vbox1), delete_btn, FALSE, FALSE, 4);
 	gtk_box_pack_end(GTK_BOX(vbox1), close_btn, FALSE, FALSE, 4);
 
+	if (!geometry.min_height) {
+		geometry.min_width = 700;
+		geometry.min_height = 250;
+	}
+
+	gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
+				      GDK_HINT_MIN_SIZE);
+	gtk_widget_set_size_request(window, prefs_common.sslmanwin_width,
+				    prefs_common.sslmanwin_height);
+
 	gtk_widget_show(certlist);
 	gtk_widget_show(scroll);
 	gtk_widget_show(hbox1);

commit e493fa7e932d10c03356d32ea51ace8b9e700430
Author: wwp <subscript at free.fr>
Date:   Tue Dec 18 10:14:08 2018 +0100

    Remember 'apply tags' window size, this feature has gone (accidentally?) since 3.0.2cvs103.

diff --git a/src/edittags.c b/src/edittags.c
index 0032dc3..d86365b 100644
--- a/src/edittags.c
+++ b/src/edittags.c
@@ -517,6 +517,18 @@ static gboolean apply_window_add_key_pressed(GtkWidget *widget, GdkEventKey *eve
 	return FALSE;
 }
 
+/*!
+ *\brief	Save Gtk object size to prefs dataset
+ */
+static void apply_window_size_allocate_cb(GtkWidget *widget,
+					 GtkAllocation *allocation)
+{
+	cm_return_if_fail(allocation != NULL);
+
+	prefs_common.tagswin_width = allocation->width;
+	prefs_common.tagswin_height = allocation->height;
+}
+
 static void apply_window_create(void) 
 {
 	GtkWidget *window;
@@ -530,6 +542,7 @@ static void apply_window_create(void)
 	GtkWidget *new_tag_entry;
 	GtkWidget *add_btn;
 	GtkWidget *del_btn;
+	static GdkGeometry geometry;
 
 	window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "tag_apply_window");
 	gtk_window_set_title (GTK_WINDOW(window),
@@ -540,6 +553,8 @@ static void apply_window_create(void)
 	gtk_window_set_resizable(GTK_WINDOW (window), TRUE);
 	g_signal_connect(G_OBJECT(window), "delete_event",
 			 G_CALLBACK(apply_window_close_cb), NULL);
+	g_signal_connect(G_OBJECT(window), "size_allocate",
+			 G_CALLBACK(apply_window_size_allocate_cb), NULL);
 	g_signal_connect(G_OBJECT(window), "key_press_event",
 			 G_CALLBACK(apply_window_key_pressed), NULL);
 	MANAGE_WINDOW_SIGNALS_CONNECT (window);
@@ -588,8 +603,6 @@ static void apply_window_create(void)
 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
 				       GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
 				       
-	gtk_widget_set_size_request(scrolledwin, 500, 250);
-
 	gtk_container_add(GTK_CONTAINER(scrolledwin), taglist);
 	gtk_box_pack_start(GTK_BOX(vbox1), scrolledwin, TRUE, TRUE, 0);
 	gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, FALSE, 0);
@@ -602,6 +615,16 @@ static void apply_window_create(void)
 	gtk_widget_show(close_btn);
 	gtk_container_add(GTK_CONTAINER (window), vbox1);
 
+	if (!geometry.min_height) {
+		geometry.min_width = 500;
+		geometry.min_height = 250;
+	}
+
+	gtk_window_set_geometry_hints(GTK_WINDOW(window), NULL, &geometry,
+				      GDK_HINT_MIN_SIZE);
+	gtk_widget_set_size_request(window, prefs_common.tagswin_width,
+				    prefs_common.tagswin_height);
+
 	applywindow.window = window;
 	applywindow.hbox1 = hbox1;
 	applywindow.vbox1 = vbox1;

commit b3f1cc12f98f399675c9d58e0b76525b34af2b12
Author: wwp <subscript at free.fr>
Date:   Mon Dec 17 21:31:19 2018 +0100

    Clean-up: remove trailing spaces.

diff --git a/src/common/utils.c b/src/common/utils.c
index 0e6e674..2e646ba 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -191,7 +191,7 @@ gchar *itos(gint n)
 gchar *to_human_readable(goffset size)
 {
 	static gchar str[14];
-	static gchar *b_format = NULL, *kb_format = NULL, 
+	static gchar *b_format = NULL, *kb_format = NULL,
 		     *mb_format = NULL, *gb_format = NULL;
 	register int t = 0, r = 0;
 	if (b_format == NULL) {
@@ -200,7 +200,7 @@ gchar *to_human_readable(goffset size)
 		mb_format = _("%d.%02dMB");
 		gb_format = _("%.2fGB");
 	}
-	
+
 	if (size < (goffset)1024) {
 		g_snprintf(str, sizeof(str), b_format, (gint)size);
 		return str;
@@ -1655,7 +1655,7 @@ const gchar *get_locale_dir(void)
 #endif
 	if (!loc_dir)
 		loc_dir = LOCALEDIR;
-	
+
 	return loc_dir;
 }
 
@@ -1718,11 +1718,11 @@ void set_rc_dir(const gchar *dir)
 		rc_dir_alt = TRUE;
 
 		claws_rc_dir = canonical_dir;
-		
+
 		len = strlen(claws_rc_dir);
 		if (claws_rc_dir[len - 1] == G_DIR_SEPARATOR)
 			claws_rc_dir[len - 1] = '\0';
-		
+
 		debug_print("set rc_dir to %s\n", claws_rc_dir);
 		if (!is_dir_exist(claws_rc_dir)) {
 			if (make_dir_hier(claws_rc_dir) != 0) {
@@ -1794,7 +1794,7 @@ const gchar *w32_get_cert_file(void)
 		cert_file = g_strconcat(w32_get_module_dir(),
 				 "\\share\\claws-mail\\",
 				"ca-certificates.crt",
-				NULL);	
+				NULL);
 	return cert_file;
 }
 #endif
@@ -1826,10 +1826,10 @@ const gchar *get_plugin_dir(void)
 	else {
 		static gchar *plugin_dir = NULL;
 		if (!plugin_dir)
-			plugin_dir = g_strconcat(get_rc_dir(), 
-				G_DIR_SEPARATOR_S, "plugins", 
+			plugin_dir = g_strconcat(get_rc_dir(),
+				G_DIR_SEPARATOR_S, "plugins",
 				G_DIR_SEPARATOR_S, NULL);
-		return plugin_dir;			
+		return plugin_dir;
 	}
 #endif
 }
@@ -2496,7 +2496,7 @@ char *fgets_crlf(char *buf, int size, FILE *stream)
 
 	*cs = '\0';
 
-	return buf;	
+	return buf;
 }
 
 static gint execute_async(gchar *const argv[], const gchar *working_directory)
@@ -2748,7 +2748,7 @@ time_t tzoffset_sec(time_t *now)
 #ifdef G_OS_WIN32
 	if (now && *now < 0)
 		return 0;
-#endif	
+#endif
 	gmt = *gmtime_r(now, &buf1);
 	lt = localtime_r(now, &buf2);
 
@@ -3511,7 +3511,7 @@ search_again:
 			start++;
 
 		*bp = start;
-		
+
 		/* check if there are quotes (to skip , in them) */
 		if (*start == '"') {
 			start_quote = start;
@@ -3521,12 +3521,12 @@ search_again:
 			start_quote = NULL;
 			end_quote = NULL;
 		}
-		
+
 		/* skip anything between quotes */
 		if (start_quote && end_quote) {
 			start = end_quote;
-			
-		} 
+
+		}
 
 		/* find end (either , or ; or end of line) */
 		if (strstr(start, ",") && strstr(start, ";"))
@@ -3781,13 +3781,13 @@ static gchar *mailcap_get_command_in_file(const gchar *path, const gchar *type,
 					testcmd[strlen(testcmd)-1] = '\0';
 				while (testcmd[strlen(testcmd)-1] == ' ' || testcmd[strlen(testcmd)-1] == '\t')
 					testcmd[strlen(testcmd)-1] = '\0';
-					
+
 				if (strstr(testcmd, "%s")) {
 					gchar *tmp = g_strdup_printf(testcmd, file_to_open);
 					gint res = system(tmp);
 					g_free(tmp);
 					g_free(orig_testcmd);
-					
+
 					if (res != 0) {
 						g_strfreev(parts);
 						continue;
@@ -3795,14 +3795,14 @@ static gchar *mailcap_get_command_in_file(const gchar *path, const gchar *type,
 				} else {
 					gint res = system(testcmd);
 					g_free(orig_testcmd);
-					
+
 					if (res != 0) {
 						g_strfreev(parts);
 						continue;
 					}
 				}
 			}
-			
+
 			trimmed = parts[1];
 			while (trimmed[0] == ' ' || trimmed[0] == '\t')
 				trimmed++;
@@ -3905,7 +3905,7 @@ void mailcap_update_default(const gchar *type, const gchar *command)
 
 	if (claws_safe_fclose(outfp) == EOF)
 		err = TRUE;
-		
+
 	if (!err)
 		g_rename(outpath, path);
 
@@ -3963,10 +3963,10 @@ gboolean sc_g_slist_bigger(GSList *list, gint max)
 }
 
 const gchar *daynames[] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
-const gchar *monthnames[] = {NULL, NULL, NULL, NULL, NULL, NULL, 
+const gchar *monthnames[] = {NULL, NULL, NULL, NULL, NULL, NULL,
 			     NULL, NULL, NULL, NULL, NULL, NULL};
 const gchar *s_daynames[] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
-const gchar *s_monthnames[] = {NULL, NULL, NULL, NULL, NULL, NULL, 
+const gchar *s_monthnames[] = {NULL, NULL, NULL, NULL, NULL, NULL,
 			     NULL, NULL, NULL, NULL, NULL, NULL};
 
 gint daynames_len[] =     {0,0,0,0,0,0,0};
@@ -4019,7 +4019,7 @@ static void init_time_names(void)
 	s_daynames[4] = C_("Abbr. day name for use by strftime", "Thu");
 	s_daynames[5] = C_("Abbr. day name for use by strftime", "Fri");
 	s_daynames[6] = C_("Abbr. day name for use by strftime", "Sat");
-	
+
 	s_monthnames[0] = C_("Abbr. month name for use by strftime", "Jan");
 	s_monthnames[1] = C_("Abbr. month name for use by strftime", "Feb");
 	s_monthnames[2] = C_("Abbr. month name for use by strftime", "Mar");
@@ -4046,7 +4046,7 @@ static void init_time_names(void)
 	s_pm_up = C_("For use by strftime (afternoon)", "PM");
 	s_am_low = C_("For use by strftime (morning, lowercase)", "am");
 	s_pm_low = C_("For use by strftime (afternoon, lowercase)", "pm");
-	
+
 	s_am_up_len = strlen(s_am_up);
 	s_pm_up_len = strlen(s_pm_up);
 	s_am_low_len = strlen(s_am_low);
@@ -4069,13 +4069,13 @@ size_t fast_strftime(gchar *buf, gint buflen, const gchar *format, struct tm *lt
 	gint total_done = 0;
 	gchar subbuf[64], subfmt[64];
 	static time_t last_tzset = (time_t)0;
-	
+
 	if (!time_names_init_done)
 		init_time_names();
-	
+
 	if (format == NULL || lt == NULL)
 		return 0;
-		
+
 	if (last_tzset != time(NULL)) {
 		tzset();
 		last_tzset = time(NULL);
@@ -4140,7 +4140,7 @@ size_t fast_strftime(gchar *buf, gint buflen, const gchar *format, struct tm *lt
 				break;
 			case 'F':
 				len = 10; CHECK_SIZE();
-				snprintf(curpos, buflen - total_done, "%4d-%02d-%02d", 
+				snprintf(curpos, buflen - total_done, "%4d-%02d-%02d",
 					lt->tm_year + 1900, lt->tm_mon +1, lt->tm_mday);
 				break;
 			case 'H':
@@ -4306,7 +4306,7 @@ size_t fast_strftime(gchar *buf, gint buflen, const gchar *format, struct tm *lt
 			format++;
 		} else {
 			int len = 1; CHECK_SIZE();
-			*curpos++ = *format++; 
+			*curpos++ = *format++;
 		}
 	}
 	*curpos = '\0';
@@ -4407,7 +4407,7 @@ static GSList *cm_split_path(const gchar *filename, int depth)
 				return NULL;
 			}
 			else /* Remove the last inserted element */
-				canonical_parts = 
+				canonical_parts =
 					g_slist_delete_link(canonical_parts,
 							    canonical_parts);
 		} else {
@@ -4440,7 +4440,7 @@ static GSList *cm_split_path(const gchar *filename, int depth)
 
 				if (!g_path_is_absolute(target)) {
 					/* remove the last inserted element */
-					canonical_parts = 
+					canonical_parts =
 						g_slist_delete_link(canonical_parts,
 							    canonical_parts);
 					/* add the target */
@@ -4494,7 +4494,7 @@ int cm_canonicalize_filename(const gchar *filename, gchar **canonical_name) {
 		gchar *cur = g_get_current_dir();
 		gchar *absolute_filename = g_strconcat(cur, G_DIR_SEPARATOR_S,
 						       filename, NULL);
-		
+
 		canonical_parts = cm_split_path(absolute_filename, 0);
 		g_free(absolute_filename);
 		g_free(cur);
@@ -4637,11 +4637,11 @@ gboolean get_serverportfp_from_filename(const gchar *str, gchar **server, gchar
 					if (strncmp(pos + 3, ":", 1) == 0) {
 						dotfp_pos = pos;
 					} else {
-						dotport_pos = pos;	
+						dotport_pos = pos;
 					}
 				} else {
 					/* match the port number */
-					dotport_pos = pos;	
+					dotport_pos = pos;
 				}
 			}
 		}
diff --git a/src/common/utils.h b/src/common/utils.h
index 1799935..64a639f 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -340,8 +340,8 @@ void unfold_line			(gchar		*str);
 void subst_char				(gchar		*str,
 					 gchar		 orig,
 					 gchar		 subst);
-void subst_chars			(gchar 		*str, 	
-					 gchar 		*orig, 
+void subst_chars			(gchar 		*str,
+					 gchar 		*orig,
 					 gchar 		subst);
 void subst_for_filename			(gchar		*str);
 void subst_for_shellsafe_filename	(gchar		*str);
@@ -367,8 +367,8 @@ gchar *get_uri_path			(const gchar	*uri);
 gint get_uri_len			(const gchar	*str);
 void decode_uri				(gchar		*decoded_uri,
 					 const gchar	*encoded_uri);
-void decode_uri_with_plus		(gchar 		*decoded_uri, 
-					 const gchar 	*encoded_uri, 
+void decode_uri_with_plus		(gchar 		*decoded_uri,
+					 const gchar 	*encoded_uri,
 					 gboolean 	 with_plus);
 gint scan_mailto_url			(const gchar	*mailto,
 					 gchar	       **from,
@@ -452,9 +452,9 @@ void get_rfc822_date		(gchar		*buf,
 void get_rfc822_date_hide_tz	(gchar		*buf,
 				 gint		 len);
 
-size_t fast_strftime		(gchar 			*buf, 
-				 gint 			 buflen, 
-				 const gchar 		*format, 
+size_t fast_strftime		(gchar 			*buf,
+				 gint 			 buflen,
+				 const gchar 		*format,
 				 struct tm 		*lt);
 
 /* debugging */
@@ -490,7 +490,7 @@ void get_hex_str(gchar *out, guchar ch);
 typedef struct AutoPointer	GAuto;
 GType g_auto_pointer_register		(void);
 GAuto *g_auto_pointer_new		(gpointer pointer);
-GAuto *g_auto_pointer_new_with_free	(gpointer p, 
+GAuto *g_auto_pointer_new_with_free	(gpointer p,
 					 GFreeFunc free);
 gpointer g_auto_pointer_get_ptr		(GAuto *auto_ptr);
 GAuto *g_auto_pointer_copy		(GAuto *auto_ptr);
@@ -503,9 +503,9 @@ gboolean get_uri_part	(const gchar *start,
 		   	 gboolean hdr);
 gchar *make_uri_string	(const gchar *bp,
 			 const gchar *ep);
-gboolean get_email_part	(const gchar *start, 
+gboolean get_email_part	(const gchar *start,
 			 const gchar *scanpos,
-			 const gchar **bp, 
+			 const gchar **bp,
 			 const gchar **ep,
 			 gboolean hdr);
 gchar *make_email_string(const gchar *bp,
@@ -513,7 +513,7 @@ gchar *make_email_string(const gchar *bp,
 gchar *make_http_string (const gchar *bp,
 			 const gchar *ep);
 
-gchar *mailcap_get_command_for_type(const gchar *type, 
+gchar *mailcap_get_command_for_type(const gchar *type,
 				    const gchar *file_to_open);
 void mailcap_update_default	   (const gchar *type,
 				    const gchar *command);

commit 85e51d737624dc20140bca28ce35e11456b97cba
Author: wwp <subscript at free.fr>
Date:   Mon Dec 17 21:11:19 2018 +0100

    Fix parsing of cert filename, prevent the Tools / SSL/TLS Certificates dialog from crashing when cert filenames contain a fingerprint. Move the parser func to utils.[ch].

diff --git a/src/common/utils.c b/src/common/utils.c
index b9a6f95..0e6e674 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -4611,3 +4611,60 @@ get_random_bytes(void *buf, size_t count)
 
 	return TRUE;
 }
+
+/* returns FALSE if parsing failed, otherwise returns TRUE and sets *server, *port
+   and eventually *fp from filename (if not NULL, they must be free'd by caller after
+   user.
+   filenames we expect: 'host.name.port.cert' or 'host.name.port.f:i:n:g:e:r:p:r:i:n:t.cert' */
+gboolean get_serverportfp_from_filename(const gchar *str, gchar **server, gchar **port, gchar **fp)
+{
+	const gchar *pos, *dotport_pos = NULL, *dotcert_pos = NULL, *dotfp_pos = NULL;
+
+	g_return_val_if_fail(str != NULL, FALSE);
+
+	pos = str + strlen(str) - 1;
+	while ((pos > str) && !dotport_pos) {
+		if (*pos == '.') {
+			if (!dotcert_pos) {
+				/* match the .cert suffix */
+				if (strcmp(pos, ".cert") == 0) {
+					dotcert_pos = pos;
+				}
+			} else {
+				if (!dotfp_pos) {
+					/* match an eventual fingerprint */
+					/* or the port number */
+					if (strncmp(pos + 3, ":", 1) == 0) {
+						dotfp_pos = pos;
+					} else {
+						dotport_pos = pos;	
+					}
+				} else {
+					/* match the port number */
+					dotport_pos = pos;	
+				}
+			}
+		}
+		pos--;
+	}
+	if (!dotport_pos || !dotcert_pos) {
+		g_warning("could not parse filename %s", str);
+		return FALSE;
+	}
+
+	*server = g_strndup(str, dotport_pos - str);
+	if (dotfp_pos) {
+		*port = g_strndup(dotport_pos + 1, dotfp_pos - dotport_pos - 1);
+		*fp = g_strndup(dotfp_pos + 1, dotcert_pos - dotfp_pos - 1);
+	} else {
+		*port = g_strndup(dotport_pos + 1, dotcert_pos - dotport_pos - 1);
+		*fp = NULL;
+	}
+
+	debug_print("filename='%s' => server='%s' port='%s' fp='%s'\n", str, *server, *port, *fp);
+	if (!*server || !*port)
+		return FALSE;
+	else
+		return TRUE;
+}
+
diff --git a/src/common/utils.h b/src/common/utils.h
index 40c3576..1799935 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -541,4 +541,6 @@ gboolean get_random_bytes(void *buf, size_t count);
 }
 #endif
 
+gboolean get_serverportfp_from_filename(const gchar *str, gchar **server, gchar **port, gchar **fp);
+
 #endif /* __UTILS_H__ */
diff --git a/src/ssl_manager.c b/src/ssl_manager.c
index 495edf7..f51ca33 100644
--- a/src/ssl_manager.c
+++ b/src/ssl_manager.c
@@ -164,7 +164,6 @@ static GtkWidget *ssl_manager_list_view_create	(void)
 	ssl_manager_create_list_view_columns(GTK_WIDGET(list_view));
 
 	return GTK_WIDGET(list_view);
-
 }
 
 void ssl_manager_create(void)
@@ -240,58 +239,6 @@ void ssl_manager_create(void)
 	gtk_widget_show(window);
 }
 
-static gboolean get_serverport(const gchar *str, gchar **server, gchar **port)
-{
-	const gchar *pos, *prevpos;
-
-	g_return_val_if_fail(str != NULL, FALSE);
-
-	/* We expect 'host.name.port.cert' here, only set
-	 * server and port if we find that.
-	 * Validity of string in port should be checked by caller. */
-	for (prevpos = str, pos = strstr(str, ".");
-			pos != NULL;
-			prevpos = pos, pos = strstr(pos+1, ".")) {
-		if (!strcmp(pos, ".cert")) {
-			if (prevpos > str) {
-				*server = g_strndup(str, prevpos - str);
-				*port = g_strndup(prevpos+1, pos - prevpos - 1);
-			} else {
-				*server = *port = NULL;
-			}
-
-			return TRUE;
-		}
-	}
-
-	return FALSE;
-}
-
-static char *get_fingerprint(const char *str)
-{
-	char *ret = NULL, *tmp = g_strdup(str), *tmp2 = tmp;
-	char *previous_pos = NULL, *last_pos = NULL;
-
-	if (!strchr(tmp, ':')) {
-		/* no fingerprint */
-		if (strstr(tmp, ".cert"))
-			*(strstr(tmp, ".cert")+1) = '.';
-	}
-
-	while (tmp2 && (tmp2 = strstr(tmp2,".")) != NULL) {
-		tmp2++;
-		previous_pos = last_pos;
-		last_pos = tmp2;
-	}
-	if (last_pos && previous_pos && (int)(last_pos - previous_pos - 1) > 0)
-		ret = g_strndup(previous_pos, (int)(last_pos - previous_pos - 1));
-	else
-		ret = NULL;
-	g_free(tmp);
-	return ret;
-	
-}
-
 static void ssl_manager_list_view_insert_cert(GtkWidget *list_view,
 						  GtkTreeIter *row_iter,
 						  gchar *host, 
@@ -307,6 +254,8 @@ static void ssl_manager_list_view_insert_cert(GtkWidget *list_view,
 	GtkListStore *list_store = GTK_LIST_STORE(gtk_tree_view_get_model
 					(GTK_TREE_VIEW(list_view)));
 
+	g_return_if_fail(cert != NULL);
+
 	exp_time_t = gnutls_x509_crt_get_expiration_time(cert->x509_cert);
 
 	memset(buf, 0, sizeof(buf));
@@ -321,7 +270,7 @@ static void ssl_manager_list_view_insert_cert(GtkWidget *list_view,
 
 	sig_status = ssl_certificate_check_signer(cert, cert->status);
 
-	if (sig_status==NULL)
+	if (sig_status == NULL)
 		sig_status = g_strdup_printf(_("Correct%s"),exp_time_t < time(NULL)? _(" (expired)"): "");
 	else {
 		 weight = PANGO_WEIGHT_BOLD;
@@ -380,21 +329,21 @@ static void ssl_manager_load_certs (void)
 		if(strstr(d, ".cert") != d + (strlen(d) - strlen(".cert"))) 
 			continue;
 
-		get_serverport(d, &server, &port);
-		fp = get_fingerprint(d);
+		if (get_serverportfp_from_filename(d, &server, &port, &fp)) {
 
-		if (server != NULL && port != NULL) {
-			gint portnum = atoi(port);
-			if (portnum > 0 && portnum <= 65535) {
-				cert = ssl_certificate_find(server, portnum, fp);
-				ssl_manager_list_view_insert_cert(manager.certlist, NULL,
-						server, port, cert);
+			if (server != NULL && port != NULL) {
+				gint portnum = atoi(port);
+				if (portnum > 0 && portnum <= 65535) {
+					cert = ssl_certificate_find(server, portnum, fp);
+					ssl_manager_list_view_insert_cert(manager.certlist, NULL,
+							server, port, cert);
+				}
 			}
-		}
 		
-		g_free(server);
-		g_free(port);
-		g_free(fp);
+			g_free(server);
+			g_free(port);
+			g_free(fp);
+		}
 		row++;
 	}
 	g_dir_close(dir);

commit a2f80ff8b7ddd630c1f9ce675fc8d2742faa798a
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Mon Dec 17 20:26:48 2018 +0100

    Make Delete key in TLS certificate manager delete selected certificate.

diff --git a/src/ssl_manager.c b/src/ssl_manager.c
index a51b016..495edf7 100644
--- a/src/ssl_manager.c
+++ b/src/ssl_manager.c
@@ -414,8 +414,14 @@ static void ssl_manager_close_cb(GtkWidget *widget,
 
 static gboolean key_pressed(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
-	if (event && event->keyval == GDK_KEY_Escape)
+	if (!event)
+		return FALSE;
+
+	if (event->keyval == GDK_KEY_Escape)
 		ssl_manager_close();
+	else if (event->keyval == GDK_KEY_Delete)
+		ssl_manager_delete_cb(manager.delete_btn, NULL);
+
 	return FALSE;
 }
 

commit 8a6bba660a93192b78978933928589ff8a1e9f75
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Mon Dec 17 20:20:24 2018 +0100

    Remove code duplication in get_certificate_path().

diff --git a/src/common/ssl_certificate.c b/src/common/ssl_certificate.c
index 7d5d50a..7c8a244 100644
--- a/src/common/ssl_certificate.c
+++ b/src/common/ssl_certificate.c
@@ -59,19 +59,15 @@ static gchar *get_certificate_path(const gchar *host, const gchar *port, const g
 
 	if (fp != NULL && prefs_common_unsafe_ssl_certs()) {
 		filename = g_strconcat(host, ".", port, ".", fp, ".cert", NULL);
-		subst_for_filename(filename);
-
-		ret = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
-			  "certs", G_DIR_SEPARATOR_S,
-			  filename, NULL);
 	} else {
 		filename = g_strconcat(host, ".", port, ".cert", NULL);
-		subst_for_filename(filename);
-
-		ret = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
-			  "certs", G_DIR_SEPARATOR_S,
-			  filename, NULL);
 	}
+	subst_for_filename(filename);
+
+	ret = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+		  "certs", G_DIR_SEPARATOR_S,
+		  filename, NULL);
+
 	g_free(filename);
 	return ret;
 }

commit b42968f69c8c870c4e4c586fb0025179cc649c3d
Author: Paul <paul at claws-mail.org>
Date:   Mon Dec 17 11:20:13 2018 +0000

    fix bug 4134, ''Save message to' option not set when it should be'

diff --git a/src/compose.c b/src/compose.c
index 3ec9ce7..d8bb181 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -10145,7 +10145,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);

commit bf3eb7fcf23e44fa1fdc7b320c5f4cee0233f3c2
Author: Ricardo Mones <ricardo at mones.org>
Date:   Sat Dec 15 20:50:51 2018 +0100

    Fix build on Hurd
    
    Error was “mailimf_types_helper.c:1265:13: error: 'HOST_NAME_MAX'
    undeclared (first use in this function); did you mean 'NAME_MAX'?”
    
    Completes commit 3a482f4d25110e588ef58d5ee67fa4216a6b631d where this
    define was used first.

diff --git a/src/common/utils.h b/src/common/utils.h
index 445d1e3..40c3576 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -47,10 +47,13 @@
 #  include <wchar.h>
 #endif
 
-/* The Hurd doesn't have this limit */
+/* The Hurd doesn't have these limits */
 #ifndef PATH_MAX
   #define PATH_MAX 4196
 #endif
+#ifndef HOST_NAME_MAX
+  #define HOST_NAME_MAX 256
+#endif
 
 #ifdef G_OS_WIN32
 
diff --git a/src/plugins/mailmbox/mailimf_types_helper.c b/src/plugins/mailmbox/mailimf_types_helper.c
index 67e921f..eadb043 100644
--- a/src/plugins/mailmbox/mailimf_types_helper.c
+++ b/src/plugins/mailmbox/mailimf_types_helper.c
@@ -35,10 +35,10 @@
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
-#include <limits.h>
 #include <errno.h>
 
 #include "mailimf.h"
+#include "utils.h"
 
 struct mailimf_mailbox_list *
 mailimf_mailbox_list_new_empty()

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list