Re: Unexpected filtering of headers



On 29.06.2004 13:57:15, Andreas Schmidt wrote:
On 2004.06.29 19:18, manu wrote:

Thanks anyway for your effort (if only the patch could make it now into 2.0.x :-)

OK try this one please. It compiles for me, that's the best I can tell for now ;-)

It compiles here, too. But on accessing the Inbox, it crashes right away.

Ooops sorry. HEAD is different from 2.0.x and I forgot it!
Here is a new patch (it replaces the previous one, you have to patch - R).
Hope it works OK now.
Bye
Manu
diff -u /home/manu/prog/balsa-2-0/balsa/libbalsa/filter.c balsa/libbalsa/filter.c
--- /home/manu/prog/balsa-2-0/balsa/libbalsa/filter.c	2004-03-12 08:54:03.000000000 -0700
+++ balsa/libbalsa/filter.c	2004-06-29 14:03:51.000000000 -0600
@@ -176,16 +176,22 @@
 	}
 	if (CONDITION_CHKMATCH(cond,CONDITION_MATCH_US_HEAD)) {
 	    if (cond->user_header) {
-		GList * header =
+		GList * headers =
 		    libbalsa_message_find_user_hdr(message, cond->user_header);
 
-		if (header) {
-		    gchar ** tmp = header->data;
-		    if (in_string_utf8(tmp[1],cond->match.string)) {
+ 		GList * list;
+  
+ 		for (list = headers; list; list = g_list_next(list)) {
+ 		    gchar * tmp = list->data;
+
+		    if (in_string_utf8(tmp, cond->match.string)) {
 			match = TRUE;
 			break;
 		    }
 		}
+ 		g_list_foreach(headers, (GFunc) g_free, NULL);
+ 		g_list_free(headers);
+ 		if (match) break;
 	    }
 	}
 	if (CONDITION_CHKMATCH(cond,CONDITION_MATCH_BODY)) {
@@ -253,16 +259,22 @@
 	    }
 	    if (CONDITION_CHKMATCH(cond,CONDITION_MATCH_US_HEAD)) {
 		if (cond->user_header) {
-		    GList * header =
-			libbalsa_message_find_user_hdr(message, cond->user_header);
+		    GList * headers =
+			libbalsa_message_find_user_hdr(message,
+						       cond->user_header);
+		    GList * list;
 		    
-		    if (header) {
-			gchar ** tmp = header->data;
-			if (tmp[1]) {
-			    match=REGEXEC(*(regex->compiled),tmp[1])==0;
-			    if (match) break;
+		    for (list = headers; list; list = g_list_next(list)) {
+			gchar * tmp = list->data;
+			
+			if (REGEXEC(*(regex->compiled), tmp)==0) {
+			    match = TRUE;
+			    break;
 			}
 		    }
+		    g_list_foreach(headers, (GFunc) g_free, NULL);
+		    g_list_free(headers);
+		    if (match) break;
 		}
 	    }
 	    if (CONDITION_CHKMATCH(cond,CONDITION_MATCH_BODY)) {
diff -u /home/manu/prog/balsa-2-0/balsa/libbalsa/message.c balsa/libbalsa/message.c
--- /home/manu/prog/balsa-2-0/balsa/libbalsa/message.c	2004-02-08 19:41:46.000000000 -0700
+++ balsa/libbalsa/message.c	2004-06-29 10:58:32.000000000 -0600
@@ -363,12 +363,16 @@
 }
 
 /** libbalsa_message_find_user_hdr:
-    returns.... list element matching given header.
+    returns.... list of header values (strings) matching given header.
+    Note : it seems that it is common to have several user
+    header having the same name.
+    This list must be freed by g_list_free(), and the strings
+    in it must be freed also (g_list_for_each(list, g_free()))!
 */
 GList *
 libbalsa_message_find_user_hdr(LibBalsaMessage * message, const gchar * find)
 {
-    GList* list;
+    GList* list, * results = NULL;
     gchar** tmp;
     LibBalsaMessageHeaders *headers = message->headers;
     
@@ -379,11 +383,11 @@
     for (list = headers->user_hdrs; list; list = g_list_next(list)) {
         tmp = list->data;
         
-        if (g_ascii_strncasecmp(tmp[0], find, strlen(find)) == 0) 
-            return list;
+        if (g_ascii_strncasecmp(tmp[0], find, strlen(find)) == 0)
+	    results = g_list_prepend(results,g_strdup(tmp[1]));
     }
     
-    return NULL;
+    return results;
 }
 
 /* libbalsa_message_user_hdrs,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]