From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id BBF791F910 for ; Fri, 25 Nov 2022 11:44:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1669376675; bh=ClTtW4cIEratsp6QvckAsHcKCdNxV/b8C/P5Wnqfh5M=; h=From:To:Subject:Date:From; b=EEyBOqdQsBIVsG2zLm7y5Ni0tpEyv7HvAEviRmH7lUO3YqQnfy6d4PfY9geV7sWWx FPg08/uLfSnokOZFOxYXeH77diF8AUjydzRzfQRsRNPcFi2ZjR3CTMWWedOHc0KrZt GLMU6LF/PcLodxRNjYgSh29e5os6UlctHvGoQ/xA= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] SaPlugin::ListMirror: follow RFC 2919 List-ID rules Date: Fri, 25 Nov 2022 11:44:35 +0000 Message-Id: <20221125114435.499-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-ID headers are sometimes populated with a descriptive phrase before the angle-bracketed value and making things difficult to match. Tweak our handling to allow checking the angle-bracketed portion only in accordance with RFC 2919. Handling of all other headers and senselessly non-bracketed values for List-ID remain unchanged. --- lib/PublicInbox/SaPlugin/ListMirror.pm | 10 +++++++-- lib/PublicInbox/SaPlugin/ListMirror.pod | 27 +++++++++++++++++-------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/lib/PublicInbox/SaPlugin/ListMirror.pm b/lib/PublicInbox/SaPlugin/ListMirror.pm index 9acf86c0..06903cad 100644 --- a/lib/PublicInbox/SaPlugin/ListMirror.pm +++ b/lib/PublicInbox/SaPlugin/ListMirror.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2021 all contributors +# Copyright (C) all contributors # License: AGPL-3.0+ # SpamAssassin rules useful for running a mailing list mirror. We want to: @@ -39,7 +39,11 @@ sub check_list_mirror_received { my $v = $pms->get($hdr) or next; local $/ = "\n"; chomp $v; - next if $v ne $hval; + if (ref($hval)) { + next if $v !~ $hval; + } else { + next if $v ne $hval; + } return 1 if $recvd !~ $host_re; } @@ -91,6 +95,8 @@ sub config_list_mirror { $host_glob =~ s!(.)!$patmap{$1} || "\Q$1"!ge; my $host_re = qr/\A\s*from\s+$host_glob(?:\s|$)/si; + (lc($hdr) eq 'list-id' && $hval =~ /<([^>]+)>/) and + $hval = qr/\A<\Q$1\E>\z/; push @{$self->{list_mirror_check}}, [ $hdr, $hval, $host_re, $addr ]; } diff --git a/lib/PublicInbox/SaPlugin/ListMirror.pod b/lib/PublicInbox/SaPlugin/ListMirror.pod index d931d762..e6a6c2ad 100644 --- a/lib/PublicInbox/SaPlugin/ListMirror.pod +++ b/lib/PublicInbox/SaPlugin/ListMirror.pod @@ -6,11 +6,11 @@ PublicInbox::SaPlugin::ListMirror - SpamAssassin plugin for mailing list mirrors loadplugin PublicInbox::SaPlugin::ListMirror -Declare some mailing lists based on the expected List-Id value, +Declare some mailing lists based on the expected List-ID value, expected servers, and mailing list address: - list_mirror List-Id *.example.com foo@example.com - list_mirror List-Id *.example.com bar@example.com + list_mirror List-ID *.example.com foo@example.com + list_mirror List-ID *.example.com bar@example.com Bump the score for messages which come from unexpected servers: @@ -43,14 +43,25 @@ C =item list_mirror HEADER HEADER_VALUE HOSTNAME_GLOB [LIST_ADDRESS] -Declare a list based on an expected C
matching C -exactly coming from C. C is optional, +Declare a list based on an expected C
matching C +coming from C. C is optional, but may specify the address of the mailing list being mirrored. -C or C are common values of C
+C is the recommended value of C
as most +mailing lists support it. An example of C is Cfoo.example.orgE> -if C
is C. +if C
is C. + +As of public-inbox 2.0, using C as the C
and a +C contained by angle brackets (Elist-idE), +matching is done in accordance with +L. That is, +C will be a case-insensitive substring match +and ignore the optional description C as documented +in RFC 2919. + +All other C
values use exact matches for backwards-compatibility. C may be a wildcard match for machines where mail can come from or an exact match. @@ -105,7 +116,7 @@ and L +Copyright (C) all contributors L License: AGPL-3.0+ L