user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] mda: set List-ID correctly according to RFC2919
Date: Mon, 26 Jun 2017 03:07:33 +0000	[thread overview]
Message-ID: <20170626030733.6069-1-e@80x24.org> (raw)

Oops, due to an old mistake , List-ID was set incorrectly
in the MDA.  This could cause some breakage w.r.t. mail filters.
---
 lib/PublicInbox/MDA.pm | 3 ++-
 scripts/ssoma-replay   | 4 +++-
 t/httpd.t              | 2 +-
 t/nntpd.t              | 4 +++-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/MDA.pm b/lib/PublicInbox/MDA.pm
index bcf5358..6490102 100644
--- a/lib/PublicInbox/MDA.pm
+++ b/lib/PublicInbox/MDA.pm
@@ -78,7 +78,8 @@ sub set_list_headers {
 	my ($class, $simple, $dst) = @_;
 	unless (defined $simple->header('List-Id')) {
 		my $pa = $dst->{-primary_address};
-		$simple->header_set("List-Id", "<$pa>"); # RFC2919
+		$pa =~ tr/@/./; # RFC2919
+		$simple->header_set("List-Id", "<$pa>");
 	}
 
 	$simple->header_set($_) foreach @BAD_HEADERS;
diff --git a/scripts/ssoma-replay b/scripts/ssoma-replay
index 3c3fdf4..50bf456 100755
--- a/scripts/ssoma-replay
+++ b/scripts/ssoma-replay
@@ -45,7 +45,9 @@ my $body = $msg->body;
 my $list_id = $header_obj->header('List-Id');
 my ($archive_url, $user, $domain);
 if (defined $list_id) {
-	($user, $domain) = ($list_id =~ /<(.+)\@(.+)>/g);
+	# due to a bug in old versions of public-inbox, <user@domain> was used
+	# as the list-Id instead of <user.domain> as recommended in RFC2919
+	($user, $domain) = ($list_id =~ /<([^\.@]+)[\.@](.+)>/g);
 
 	if (defined $domain) {
 		$archive_url = "https://$domain/$user/";
diff --git a/t/httpd.t b/t/httpd.t
index c2e7360..d0ce394 100644
--- a/t/httpd.t
+++ b/t/httpd.t
@@ -57,7 +57,7 @@ Date: Thu, 01 Jan 1970 06:06:06 +0000
 
 nntp
 EOF
-		$mime->header_set('List-Id', "<$addr>");
+
 		my $git = PublicInbox::Git->new($maindir);
 		my $im = PublicInbox::Import->new($git, 'test', $addr);
 		$im->add($mime);
diff --git a/t/nntpd.t b/t/nntpd.t
index ad50a64..2ccc90f 100644
--- a/t/nntpd.t
+++ b/t/nntpd.t
@@ -62,7 +62,9 @@ Content-Transfer-Encoding: 8bit
 
 This is a test message for El\xc3\xa9anor
 EOF
-		$mime->header_set('List-Id', "<$addr>");
+		my $list_id = $addr;
+		$list_id =~ s/@/./;
+		$mime->header_set('List-Id', "<$list_id>");
 		$len = length($mime->as_string);
 		my $git = PublicInbox::Git->new($maindir);
 		my $im = PublicInbox::Import->new($git, 'test', $addr);
-- 
EW


                 reply	other threads:[~2017-06-26  3:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170626030733.6069-1-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).