From 56489ee40e44255f2f9a00cd608bc366d2586306 Mon Sep 17 00:00:00 2001 From: "Eric Wong (Contractor, The Linux Foundation)" Date: Thu, 5 Apr 2018 09:34:11 +0000 Subject: support altid mechanism for v2 There's enough gmane links out there in wild that it makes sense to maintain support for these mappings. --- lib/PublicInbox/Filter/RubyLang.pm | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'lib/PublicInbox/Filter') diff --git a/lib/PublicInbox/Filter/RubyLang.pm b/lib/PublicInbox/Filter/RubyLang.pm index 63e8d422..cb69e38a 100644 --- a/lib/PublicInbox/Filter/RubyLang.pm +++ b/lib/PublicInbox/Filter/RubyLang.pm @@ -6,6 +6,7 @@ package PublicInbox::Filter::RubyLang; use base qw(PublicInbox::Filter::Base); use strict; use warnings; +use PublicInbox::MID qw(mids); my $l1 = qr/Unsubscribe:\s /x; @@ -44,16 +45,23 @@ sub scrub { my $altid = $self->{-altid}; if ($altid) { my $hdr = $mime->header_obj; - my $mid = $hdr->header_raw('Message-ID'); - unless (defined $mid) { - return $self->REJECT('Message-Id missing'); + my $mids = mids($hdr); + return $self->REJECT('Message-ID missing') unless (@$mids); + my @v = $hdr->header_raw('X-Mail-Count'); + my $n; + foreach (@v) { + /\A\s*(\d+)\s*\z/ or next; + $n = $1; + last; } - my $n = $hdr->header_raw('X-Mail-Count'); - if (!defined($n) || $n !~ /\A\s*\d+\s*\z/) { + unless (defined $n) { return $self->REJECT('X-Mail-Count not numeric'); } - $mid = PublicInbox::MID::mid_clean($mid); - $altid->{mm_alt}->mid_set($n, $mid); + foreach my $mid (@$mids) { + my $r = $altid->mm_alt->mid_set($n, $mid); + next if $r == 0; + last; + } } $self->ACCEPT($mime); } -- cgit v1.2.3-24-ge0c7