From fd254c022da9e0f3e6ce793fc38e0fa2fe1ca683 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 27 Nov 2023 22:20:59 +0000 Subject: disallow NUL characters in Message-ID and List-Id While MTAs seem to stop '\0' from appearing in headers, users fetching archives via git remain susceptible to having '\0' land in archives. So we'll filter them out of Xapian and SQLite DBs to avoid interopability problems with CLI tools since there's no known messages in lore or any of my archives which feature them. Avoiding '\0' will ensure all indexed Message-IDs and List-Ids can be specified from the command-line (although some characters will still require $(printf) contortions). As with Message-ID, List-Id fields with /\n\t\r/ characters will also be stripped for indexing. I will assume whatever went wrong with the References: header in could also happen to the List-Id header. This is inspired by commit aca47e05a6026c12c768753c87e6ff769ef6bee4 (Import: Don't copy nulls from emails into git, 2018-07-07) --- lib/PublicInbox/MID.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/PublicInbox/MID.pm') diff --git a/lib/PublicInbox/MID.pm b/lib/PublicInbox/MID.pm index 97cf3a54..36c05855 100644 --- a/lib/PublicInbox/MID.pm +++ b/lib/PublicInbox/MID.pm @@ -115,7 +115,7 @@ sub uniq_mids ($;$) { my @ret; $seen ||= {}; foreach my $mid (@$mids) { - $mid =~ tr/\n\t\r//d; + $mid =~ tr/\n\t\r\0//d; if (length($mid) > MAX_MID_SIZE) { warn "Message-ID: <$mid> too long, truncating\n"; $mid = substr($mid, 0, MAX_MID_SIZE); -- cgit v1.2.3-24-ge0c7