about summary refs log tree commit homepage
path: root/lib/PublicInbox/SaPlugin/ListMirror.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-11-25 11:44:35 +0000
committerEric Wong <e@80x24.org>2022-11-26 18:46:23 +0000
commit2bacd6f4a4dbb1073d7f436411a4ed368faad37d (patch)
treef51c58eefb720d4792d1e45c53a9626e75126345 /lib/PublicInbox/SaPlugin/ListMirror.pm
parent5198c976ce8b1954f0f76a0da152cc434411f147 (diff)
downloadpublic-inbox-2bacd6f4a4dbb1073d7f436411a4ed368faad37d.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/SaPlugin/ListMirror.pm')
-rw-r--r--lib/PublicInbox/SaPlugin/ListMirror.pm10
1 files changed, 8 insertions, 2 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 <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # 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 ];
 }