On Mon, Mar 10, 2014 at 05:11:05PM +0000, Jonathan Dowland wrote: > On Thu, Mar 06, 2014 at 07:24:36PM +0000, Tom Furie wrote: > > This is the snippet from my .procmailrc for handling Debian mailing > > lists. Each list gets sorted into it's own directory. > > > > :0 > > * ^List-id: <debian-.+\.lists\.debian\.org> > > * ^List-id: <debian-\/[^\.]+ > > $MAILDIR/.Debian.$MATCH/ > > The only problem with that is that anyone can send you a mail with a > list-id header containing some encoded chars that you would not want > procmail to put verbatim into a file or folder name. A slightly safer > solution is (from http://jmtd.net/log/list_filtering/) > > :0 > * ^List-Id:.*debian.*lists\.debian\.org > { > :0 > subst=| echo "$MATCH" | sed 's/\([A-Za-z0-9-]\+\)\..*/\1/' > > :0 > $MAILDIR/$subst/ > } > > (note that my variation also removes dots, you may wish to tweak).
That rule is good, but would result in $subst being debian-user for this list or debian-security-announce for the DSA list. My version also removes dots, but allows me to serve by imap all the debian lists within a sub-heirarchy of Debian without a redundant duplication of 'debian-' The first List-id: matches debian-<any string of length >= 1>.lists.debian.org. The second matches debian-<any string of length >= 1 until a '.' is found> so $MATCH becomes 'user' in debian-user.lists.debian.org, or 'security-announce' in debian-security-announce.lists.debian.org. The message is then moved into my maildir structure. The dots in the destination are there to keep my IMAP server happy. You make a good point about potentially unwanted characters in the List-id: header, I've now limited the second pattern to alphanumerics and -. Cheers, Tom -- My opinions may have changed, but not the fact that I am right.
signature.asc
Description: Digital signature