[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    [PATCH] more mailing list magic
From:       Marc Mutz <Marc.Mutz () uni-bielefeld ! de>
Date:       2001-04-27 23:59:11
[Download RAW message or body]

Hi!

I've checked that the original mailing list magic for X-Mailing-List
assumed that the contents of that header match /^<.*>/. But the mailing
lists at vger.kernel.org don't have the angle brackets. So I modified
check_x_mailing_list to understand that, too.

I've added a new function check_list_id, which assumes the header field
to match /[^<]*<([^.]+)\./. \1 is the returned string. It works with all
KDE mailing lists that are hosted on master.kde.org, and many, many
more.

At least for me, the more valueable header for detecting mailing lists
is Delivered-to: instead of Delivered-To: (notice the uppercase T). The
latter alwasy contains my address; the former, if it exsists, a hint on
the mailing list. But I haven't changed check_delivered_to, because it
seems to additionally assume the string "mailing list" in the header and
I've yet to see such a message.

Please consider applying.

Marc

BTW: KMail (CVS from a few days ago) crashed on me multiple times when
creating some new folders. Backtrace of one of them crashes attached.

-- 
Marc Mutz <Marc@Mutz.com>     http://EncryptionHOWTO.sourceforge.net/
University of Bielefeld, Dep. of Mathematics / Dep. of Physics

PGP-keyID's:   0xd46ce9ab (RSA), 0x7ae55b9e (DSS/DH)

["kmail-ml-magic-20010428.diff;" (text/plain)]

--- mailinglist-magic.cpp.orig	Sat Apr 28 13:49:27 2001
+++ mailinglist-magic.cpp	Sat Apr 28 14:44:13 2001
@@ -1,3 +1,4 @@
+#include <kdebug.h>
 #include <kmmessage.h>
 #include <qregexp.h>
 
@@ -47,7 +48,7 @@
     return header;
 }
 
-/* X-Mailing-List: <([^@]+) */
+/* Delivered-To:: <([^@]+) */
 static QString check_delivered_to(const KMMessage  *message,
                                   QString &header_name,
                                   QString &header_value )
@@ -63,7 +64,7 @@
     return header.mid( 13, header.find( "@" ) - 13 );
 }
 
-/* X-Mailing-List: <([^@]+) */
+/* X-Mailing-List: <?([^@]+) */
 static QString check_x_mailing_list(const KMMessage  *message,
                                     QString &header_name,
                                     QString &header_value )
@@ -72,13 +73,39 @@
     if ( header.isEmpty() )
         return QString::null;
 
-    if (header.at( 0 ) != '<' || header.find( "@" ) < 2  ||
-        header.at( header.length() - 1 ) != '>')
+    if ( header.find( "@" ) < 1 )
         return QString::null;
 
     header_name = "X-Mailing-List";
     header_value = header;
-    header = header.mid(1,  header.find( "@" ) - 1);
+    if ( header[0] == '<' )
+        header = header.mid(1,  header.find( "@" ) - 1);
+    else
+        header = header.left( header.find( "@" ) );
+    return header;
+}
+
+/* List-Id: [^<]* <([^.]+) */
+static QString check_list_id(const KMMessage  *message,
+			     QString &header_name,
+			     QString &header_value )
+{
+    int lAnglePos, firstDotPos;
+    QString header = message->headerField( "List-Id" );
+    if ( header.isEmpty() )
+        return QString::null;
+
+    lAnglePos = header.find( "<" );
+    if ( lAnglePos < 0 )
+        return QString::null;
+
+    firstDotPos = header.find( ".", lAnglePos );
+    if ( firstDotPos < 0 )
+        return QString::null;
+
+    header_name = "List-Id";
+    header_value = header;
+    header = header.mid( lAnglePos + 1, firstDotPos - lAnglePos - 1 );
     return header;
 }
 
@@ -120,6 +147,7 @@
 
 MagicDetectorFunc magic_detector[] =
 {
+    check_list_id,
     check_sender,
     check_x_mailing_list,
     check_mailing_list,

["kmail.bug.bt2.txt.bz2" (application/octet-stream)]
_______________________________________________
Kmail Developers mailing list
Kmail@master.kde.org
http://master.kde.org/mailman/listinfo/kmail


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic