~rgrjr/rgrjr-scripts

439f1c88ea1e98021b92b7c33156564987039b2c — Bob Rogers 1 year, 9 months ago 7df4344
* email/qmail-deliver.pl:
   + (find_list_qmail_file):  New helper.
   + (deliver_message):  After the spam, forgery, and extension checks,
     if there is a "List-ID:" header, and a corresponding .qmail file of
     the form ".qmail-list-<id>", then use that file for delivery.
* email/test-qmail-deliver.pl:
   + Test "List-ID:" dispatch.
* email/from-emacs-dev.msg (added):
   + Test case for same.
3 files changed, 127 insertions(+), 1 deletions(-)

A email/from-emacs-dev.msg
M email/qmail-deliver.pl
M email/test-qmail-deliver.pl
A email/from-emacs-dev.msg => email/from-emacs-dev.msg +80 -0
@@ 0,0 1,80 @@
Return-Path: <emacs-devel-bounces+rogers-emacs=rgrjr.homedns.org@gnu.org>
X-Original-To: rogers@rgrjr.com
Delivered-To: rogers@rgrjr.com
Received: from rgrjr.com (rgrjr.com [69.164.211.47])
	by scorpio.rgrjr.com (Postfix on openSUSE GNU/Linux) with ESMTP id DE1705FE80
	for <rogers-emacs@rgrjr.homedns.org>; Tue,  5 Jul 2022 09:12:07 -0400 (EDT)
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17])
	by rgrjr.com (Postfix on openSUSE) with ESMTP id 691DA1D6BC2
	for <rogers-emacs@rgrjr.homedns.org>; Tue,  5 Jul 2022 13:10:31 +0000 (UTC)
Received: from localhost ([::1]:46636 helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-devel-bounces+rogers-emacs=rgrjr.homedns.org@gnu.org>)
	id 1o8iLX-0007bI-Ee
	for rogers-emacs@rgrjr.homedns.org; Tue, 05 Jul 2022 09:12:07 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:40482)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <larsi@gnus.org>) id 1o8iKK-0007HU-Ol
 for Emacs-devel@gnu.org; Tue, 05 Jul 2022 09:10:52 -0400
Received: from quimby.gnus.org ([2a01:4f9:2b:f0f::2]:33700)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <larsi@gnus.org>) id 1o8iKJ-0008BC-4A
 for Emacs-devel@gnu.org; Tue, 05 Jul 2022 09:10:52 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID
 :Date:References:In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-ID:
 Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc
 :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=3z7yArWyXS45FDZLi6ze/oSvz6UbEh7Qv+gRBq9R1jI=; b=eok8kToyQEvXoWlJw/k6xswOD5
 x4FPThA5rE13x2tJp3ZmJK710pzaUcc/UHG9rT2x0FEY+PuAAwyHXgLwHhT/9MitE59NqA9YEfvAE
 VZjH8yNyiCP6LrU0Mbc/VHVlDFvqHPSpYqjGtAh6CRkuKlg53cU1DlIQAzeXRW8fNOYc=;
Received: from [84.212.220.105] (helo=joga)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@gnus.org>)
 id 1o8iKC-00024S-T5; Tue, 05 Jul 2022 15:10:47 +0200
In-Reply-To: <87edyziu6l.fsf@gmail.com> (Robert Pluim's message of "Tue, 05
 Jul 2022 15:08:02 +0200")
References: <m2h73w3g1b.fsf@ntnu.no> <87h73v7rie.fsf@gnus.org>
 <87edyziu6l.fsf@gmail.com>
Message-ID: <87fsjf3dt8.fsf@gnus.org>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=2a01:4f9:2b:f0f::2; envelope-from=larsi@gnus.org;
 helo=quimby.gnus.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-devel>,
 <mailto:emacs-devel-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-devel>
List-Post: <mailto:emacs-devel@gnu.org>
List-Help: <mailto:emacs-devel-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-devel>,
 <mailto:emacs-devel-request@gnu.org?subject=subscribe>
Errors-To: emacs-devel-bounces+rogers-emacs=rgrjr.homedns.org@gnu.org
From: Lars Ingebrigtsen <larsi@gnus.org>
Sender: "Emacs-devel"
 <emacs-devel-bounces+rogers-emacs=rgrjr.homedns.org@gnu.org>
To: Robert Pluim <rpluim@gmail.com>
Cc: Tor Kringeland <tor.kringeland@ntnu.no>,  "Emacs-devel@gnu.org"
 <Emacs-devel@gnu.org>
Subject: Re: Prefix argument to emoji-recent etc.?
Date: Tue, 05 Jul 2022 15:10:43 +0200

Robert Pluim <rpluim@gmail.com> writes:

> I=CA=BCm kinda =F0=9F=A4=B7=F0=9F=8F=BD on it. It=CA=BCs not *that* hard =
to just insert the emoji
> and then kill it.=20

That's true, but you first have to navigate to a non-read-only buffer,
so it's potentially a series of operations just to be able to paste an
emoji into a different program.

--=20
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no


M email/qmail-deliver.pl => email/qmail-deliver.pl +36 -0
@@ 293,6 293,39 @@ sub find_extension {
    return '';
}

sub find_list_qmail_file {
    # If there is a "List-ID:" header, and a corresponding .qmail file of the
    # form ".qmail-list-<id>", then return that name.  This header looks like
    #
    #	List-Id: "Emacs development discussions." <emacs-devel.gnu.org>
    #
    # for example.
    my ($head) = @_;

    warn "find_list_qmail_file";
    my $list_id_head = $head->get('list-id')
	or return;
    chomp($list_id_head);
    warn "have list ID header '$list_id_head'"
	if $verbose_p > 1;
    # Per RFC2919 (https://datatracker.ietf.org/doc/html/rfc2919), the angle
    # brackets must appear, and there must be no comments in the header.  The
    # initial ".*" ensures that we match the last angle bracket pair, in case
    # there are angle brackets for some reason in the phrase that is allowed
    # before the list ID.
    my ($list_id) = $list_id_head =~ /^.*<([^<>]+)>/;
    return
	# If it's not there, then the "List-ID:" header is non-compliant.
	unless $list_id;
    $list_id =~ s/[^-.\w\d]+//;		# Sanitize.
    $list_id = lc($list_id);
    warn "have list_id '$list_id'"
	if $verbose_p > 1;
    my $qmail_file = ".qmail-list-$list_id";
    return $qmail_file
	if -r $qmail_file;
}

sub address_forged_p {
    # Returns true if forged-local-address.pl says it claims to be local but
    # came from somewhere else.


@@ 471,6 504,9 @@ sub deliver_message {
	process_qmail_file(".qmail-$extension", $head, $header,
			   $message_source);
    }
    elsif ($qmail_file = find_list_qmail_file($head)) {
	process_qmail_file($qmail_file, $head, $header, $message_source);
    }
    elsif (-r '.qmail') {
	process_qmail_file('.qmail', $head, $header, $message_source);
    }

M email/test-qmail-deliver.pl => email/test-qmail-deliver.pl +11 -1
@@ 8,7 8,7 @@
use strict;
use warnings;

use Test::More tests => 77;
use Test::More tests => 80;

### Subroutines.



@@ 18,6 18,7 @@ sub clean_up {
	system(qq{rm -fr $dir})
	    if -d $dir;
    }
    unlink(qw(.qmail-list-emacs-devel.gnu.org host-deadlist.tmp));
    unlink(qw(list.tmp .qmail-spam .qmail-emacs .qmail-dead));
}



@@ 258,6 259,15 @@ deliver_one('viagra-inc.text', 'spam', 9,
ok(9 == count_messages(),
   "--list-host makes no difference if not delivered from that system.");

## Test list delivery.

system('echo emacs/ > .qmail-list-emacs-devel.gnu.org');
deliver_one('from-emacs-dev.msg', 'emacs', 4,
	    sender => 'emacs-devel-bounces+etc@gnu.org',
	    verbose_p => 1, # verbose_p => 1,
	    network_prefix => '209.85.128.0/17');
ok(9 == count_messages('spam'), 'still have 9 spams');

## Tidy up.
clean_up();