Re: Unexpected filtering of headers
- From: manu <eallaud yahoo fr>
- To: Andreas Schmidt <andy space wh1 tu-dresden de>
- Cc: balsa-list gnome org
- Subject: Re: Unexpected filtering of headers
- Date: Thu, 24 Jun 2004 19:56:21 +0000
On 24.06.2004 03:13:25, Andreas Schmidt wrote:
Hi,
I just noticed that one of my filters doesn't seem to work as
expected. I've set up a filter to move mails matching the expression
"postmaster localhost" in user header "X-Original-To" to an mbox
named "Postmaster". Currently, there is one message in the Inbox that
this filter should match:
From somebody some where Thu Jun 24 08:48:59 2004
Return-Path: <somebody some where>
X-Original-To: pc localhost
X-Original-To: postmaster localhost
Alas, it does nothing. Now, when I change the filter to match
"pc localhost", it moves this mail and all others from my Inbox to
Postmaster.
The problem seems to be that the filtering routine only looks for the
first occurence of a given header. That's okay for uniq headers like
From: or To:, but it just doesn't work for headers that could get
inserted at any relay a mail is passing through. Would it be possible
to grep through the complete header part for occurences of (at
least) user headers?
Could you try the following patch (to apply to HEAD) and tell me if it
works for you (and does not break anything else ;-)
Thx
Bye
Manu
--- ../balsa-HEAD/balsa/libbalsa/message.c 2004-06-14 14:26:19.000000000 -0600
+++ balsa/libbalsa/message.c 2004-06-24 13:47:48.000000000 -0600
@@ -318,12 +318,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(), but the strings
+ in it must not be freed!
*/
GList *
libbalsa_message_find_user_hdr(LibBalsaMessage * message, const gchar * find)
{
- GList* list;
+ GList* list, * results = NULL;
gchar** tmp;
LibBalsaMessageHeaders *headers = message->headers;
@@ -334,11 +338,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,tmp[1]);
}
- return NULL;
+ return results;
}
static void
--- ../balsa-HEAD/balsa/src/sendmsg-window.c 2004-06-16 15:15:47.000000000 -0600
+++ balsa/src/sendmsg-window.c 2004-06-24 13:52:48.000000000 -0600
@@ -4410,17 +4410,24 @@
return;
}
- if ((p = libbalsa_message_find_user_hdr(message, "list-post"))
- && set_list_post_rfc2369(bsmsg, p))
+ p = libbalsa_message_find_user_hdr(message, "list-post");
+ if (p) {
+ set_list_post_rfc2369(bsmsg, p);
+ g_list_free(p);
return;
+ }
/* we didn't find "list-post", so try some nonstandard
* alternatives: */
- if ((p = libbalsa_message_find_user_hdr(message, "x-beenthere"))
- || (p = libbalsa_message_find_user_hdr(message, "x-mailing-list"))) {
- gchar **pair = p->data;
- gtk_entry_set_text(GTK_ENTRY(bsmsg->to[1]), pair[1]);
+ p = libbalsa_message_find_user_hdr(message, "x-beenthere");
+ if (!p)
+ p = libbalsa_message_find_user_hdr(message, "x-mailing-list");
+ if (p) {
+ gchar * hdr = p->data;
+
+ gtk_entry_set_text(GTK_ENTRY(bsmsg->to[1]), hdr);
+ g_list_free(p);
}
}
@@ -4429,11 +4436,9 @@
static gboolean
set_list_post_rfc2369(BalsaSendmsg * bsmsg, GList * p)
{
- gchar **pair;
gchar *url;
- pair = p->data;
- url = pair[1];
+ url = p->data;
/* RFC 2369: To allow for future extension, client
* applications MUST follow the following guidelines for
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]