[Commits] [SCM] claws branch, master, updated. 3.18.0-341-g0391e584a

wwp at claws-mail.org wwp at claws-mail.org
Wed Mar 9 18:23:01 CET 2022


The branch, master has been updated
       via  0391e584a2e44338bc19e589c727cd6a9bde2e66 (commit)
      from  294543ded5a2b6465d616957099b156efc02254c (commit)

Summary of changes:
 src/plugins/address_keeper/address_keeper.c | 62 ++++++++++++++---------------
 src/plugins/attachwarner/attachwarner.c     | 40 +++++++++----------
 src/plugins/keyword_warner/keyword_warner.c | 42 +++++++++----------
 3 files changed, 72 insertions(+), 72 deletions(-)


- Log -----------------------------------------------------------------
commit 0391e584a2e44338bc19e589c727cd6a9bde2e66
Author: wwp <subscript at free.fr>
Date:   Wed Mar 9 18:21:46 2022 +0100

    Fix crash in attachwarner and keywordwarner plugins when regexp list
    is empty. Rework a bit the logic in the addrkeeper plugin as well.

diff --git a/src/plugins/address_keeper/address_keeper.c b/src/plugins/address_keeper/address_keeper.c
index a5aab85a4..b8cf0a63b 100644
--- a/src/plugins/address_keeper/address_keeper.c
+++ b/src/plugins/address_keeper/address_keeper.c
@@ -196,39 +196,39 @@ static gboolean addrk_before_send_hook(gpointer source, gpointer data)
 	if (addkeeperprefs.block_matching_addrs != NULL
 			&& addkeeperprefs.block_matching_addrs[0] != '\0') {
 		blocked = matcherlist_new_from_lines(addkeeperprefs.block_matching_addrs, FALSE, FALSE);
-		if (blocked == NULL)
-			g_warning("couldn't allocate matcher");
-	}
-	for (cur = compose->header_list; cur != NULL; cur = cur->next) {
-		gchar *header;
-		gchar *entry;
-		header = gtk_editable_get_chars(GTK_EDITABLE(
-				gtk_bin_get_child(GTK_BIN(
-					(((ComposeHeaderEntry *)cur->data)->combo)))), 0, -1);
-		entry = gtk_editable_get_chars(GTK_EDITABLE(
-				((ComposeHeaderEntry *)cur->data)->entry), 0, -1);
-		g_strstrip(entry);
-		g_strstrip(header);
-		if (*entry != '\0') {
-			if (!g_ascii_strcasecmp(header, to_hdr)
-				&& addkeeperprefs.keep_to_addrs == TRUE) {
-				keep_if_unknown(abf, folder, entry, blocked);
-			}
-			if (!g_ascii_strcasecmp(header, cc_hdr)
-				&& addkeeperprefs.keep_cc_addrs == TRUE) {
-				keep_if_unknown(abf, folder, entry, blocked);
-			}
-			if (!g_ascii_strcasecmp(header, bcc_hdr)
-				&& addkeeperprefs.keep_bcc_addrs == TRUE) {
-				keep_if_unknown(abf, folder, entry, blocked);
+
+		if (blocked) {
+			for (cur = compose->header_list; cur != NULL; cur = cur->next) {
+				gchar *header;
+				gchar *entry;
+				header = gtk_editable_get_chars(GTK_EDITABLE(
+						gtk_bin_get_child(GTK_BIN(
+							(((ComposeHeaderEntry *)cur->data)->combo)))), 0, -1);
+				entry = gtk_editable_get_chars(GTK_EDITABLE(
+						((ComposeHeaderEntry *)cur->data)->entry), 0, -1);
+				g_strstrip(entry);
+				g_strstrip(header);
+				if (*entry != '\0') {
+					if (!g_ascii_strcasecmp(header, to_hdr)
+						&& addkeeperprefs.keep_to_addrs == TRUE) {
+						keep_if_unknown(abf, folder, entry, blocked);
+					}
+					if (!g_ascii_strcasecmp(header, cc_hdr)
+						&& addkeeperprefs.keep_cc_addrs == TRUE) {
+						keep_if_unknown(abf, folder, entry, blocked);
+					}
+					if (!g_ascii_strcasecmp(header, bcc_hdr)
+						&& addkeeperprefs.keep_bcc_addrs == TRUE) {
+						keep_if_unknown(abf, folder, entry, blocked);
+					}
+				}
+				g_free(header);
+				g_free(entry);
 			}
-		}
-		g_free(header);
-		g_free(entry);
+			matcherlist_free(blocked);
+		} else
+			g_warning("couldn't allocate matcher");
 	}
-	if (blocked != NULL)	
-		matcherlist_free(blocked);
-
 	return FALSE;	/* continue sending */
 }
 
diff --git a/src/plugins/attachwarner/attachwarner.c b/src/plugins/attachwarner/attachwarner.c
index 4c019dfd2..8684739ae 100644
--- a/src/plugins/attachwarner/attachwarner.c
+++ b/src/plugins/attachwarner/attachwarner.c
@@ -109,27 +109,27 @@ AttachWarnerMention *are_attachments_mentioned(Compose *compose)
 	AttachWarnerMention *mention = NULL;
 	MatcherList *matchers = NULL;
 
-	matchers = matcherlist_new_from_lines(attwarnerprefs.match_strings, FALSE, attwarnerprefs.case_sensitive);
-
-	if (matchers == NULL) {
-		g_warning("couldn't allocate matcher");
-		return FALSE;
+	if (attwarnerprefs.match_strings != NULL
+			&& attwarnerprefs.match_strings[0] != '\0') {
+		matchers = matcherlist_new_from_lines(attwarnerprefs.match_strings, FALSE, attwarnerprefs.case_sensitive);
+
+		if (matchers) {
+			textview = GTK_TEXT_VIEW(compose->text);
+		        textbuffer = gtk_text_view_get_buffer(textview);
+			gtk_text_buffer_get_start_iter(textbuffer, &start);
+			gtk_text_buffer_get_end_iter(textbuffer, &end);
+			text = gtk_text_buffer_get_text(textbuffer, &start, &end, FALSE);
+
+			debug_print("checking text for attachment mentions\n");
+			if (text != NULL) {
+				mention = aw_matcherlist_string_match(matchers, text, compose->account->sig_sep);
+				g_free(text);
+			}	
+			matcherlist_free(matchers);
+			debug_print("done\n");
+		} else
+			g_warning("couldn't allocate matcher");
 	}
-
-	textview = GTK_TEXT_VIEW(compose->text);
-        textbuffer = gtk_text_view_get_buffer(textview);
-	gtk_text_buffer_get_start_iter(textbuffer, &start);
-	gtk_text_buffer_get_end_iter(textbuffer, &end);
-	text = gtk_text_buffer_get_text(textbuffer, &start, &end, FALSE);
-
-	debug_print("checking text for attachment mentions\n");
-	if (text != NULL) {
-		mention = aw_matcherlist_string_match(matchers, text, compose->account->sig_sep);
-		g_free(text);
-	}	
-	if (matchers != NULL)
-		matcherlist_free(matchers);
-	debug_print("done\n");
 	return mention;
 }
 
diff --git a/src/plugins/keyword_warner/keyword_warner.c b/src/plugins/keyword_warner/keyword_warner.c
index 5745bf4a3..214a71210 100644
--- a/src/plugins/keyword_warner/keyword_warner.c
+++ b/src/plugins/keyword_warner/keyword_warner.c
@@ -109,27 +109,27 @@ KeywordWarnerMention *is_keyword_mentioned(Compose *compose)
 	KeywordWarnerMention *mention = NULL;
 	MatcherList *matchers = NULL;
 
-	matchers = matcherlist_new_from_lines(kwarnerprefs.match_strings, FALSE, kwarnerprefs.case_sensitive);
-
-	if (matchers == NULL) {
-		g_warning("couldn't allocate matcher");
-		return FALSE;
-	}
-
-	textview = GTK_TEXT_VIEW(compose->text);
-        textbuffer = gtk_text_view_get_buffer(textview);
-	gtk_text_buffer_get_start_iter(textbuffer, &start);
-	gtk_text_buffer_get_end_iter(textbuffer, &end);
-	text = gtk_text_buffer_get_text(textbuffer, &start, &end, FALSE);
-
-	debug_print("checking text for keyword mentions\n");
-	if (text != NULL) {
-		mention = kw_matcherlist_string_match(matchers, text, compose->account->sig_sep);
-		g_free(text);
-	}	
-	if (matchers != NULL)
-		matcherlist_free(matchers);
-	debug_print("done\n");
+	if (kwarnerprefs.match_strings != NULL
+			&& kwarnerprefs.match_strings[0] != '\0') {
+		matchers = matcherlist_new_from_lines(kwarnerprefs.match_strings, FALSE, kwarnerprefs.case_sensitive);
+
+		if (matchers) {
+			textview = GTK_TEXT_VIEW(compose->text);
+	        textbuffer = gtk_text_view_get_buffer(textview);
+			gtk_text_buffer_get_start_iter(textbuffer, &start);
+			gtk_text_buffer_get_end_iter(textbuffer, &end);
+			text = gtk_text_buffer_get_text(textbuffer, &start, &end, FALSE);
+
+			debug_print("checking text for keyword mentions\n");
+			if (text != NULL) {
+				mention = kw_matcherlist_string_match(matchers, text, compose->account->sig_sep);
+				g_free(text);
+			}	
+			matcherlist_free(matchers);
+			debug_print("done\n");
+		} else
+			g_warning("couldn't allocate matcher");
+	}            
 	return mention;
 }
 

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


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list