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 3/4] drop Message-IDs longer than 244 bytes
Date: Sat,  3 Oct 2015 11:14:10 +0000	[thread overview]
Message-ID: <20151003111411.1003-4-e@80x24.org> (raw)
In-Reply-To: <20151003111411.1003-1-e@80x24.org>

Xapian has this limit for terms, and there are likely no
legitimate Message-IDs (or single header lines) this long; so
there's no need to workaround this limit.
---
 lib/PublicInbox/MDA.pm       | 2 ++
 lib/PublicInbox/SearchIdx.pm | 5 +++++
 2 files changed, 7 insertions(+)

diff --git a/lib/PublicInbox/MDA.pm b/lib/PublicInbox/MDA.pm
index 25d6ae5..7025fb3 100644
--- a/lib/PublicInbox/MDA.pm
+++ b/lib/PublicInbox/MDA.pm
@@ -6,6 +6,7 @@ use warnings;
 use Email::Address;
 use Date::Parse qw(strptime);
 use constant MAX_SIZE => 1024 * 500; # same as spamc default, should be tunable
+use constant MAX_MID_SIZE => 244; # max term size - 1 in Xapian
 use constant cmd => qw/ssoma-mda -1/;
 
 # drop plus addressing for matching
@@ -20,6 +21,7 @@ sub precheck {
 	my ($klass, $filter, $address) = @_;
 	my $simple = $filter->simple;
 	my $mid = $simple->header("Message-ID");
+	return 0 if (length($mid) > MAX_MID_SIZE);
 	return 0 unless usable_str(length('<m@h>'), $mid) && $mid =~ /\@/;
 	return 0 unless usable_str(length('u@h'), $filter->from);
 	return 0 unless usable_str(length(':o'), $simple->header("Subject"));
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 8184dc7..0646cfb 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -8,6 +8,7 @@ use base qw(PublicInbox::Search);
 use PublicInbox::MID qw/mid_clean id_compress/;
 *xpfx = *PublicInbox::Search::xpfx;
 
+use constant MAX_MID_SIZE => 244; # max term size - 1 in Xapian
 use constant {
 	PERM_UMASK => 0,
 	OLD_PERM_GROUP => 1,
@@ -52,6 +53,7 @@ sub add_message {
 	my $ct_msg = $mime->header('Content-Type') || 'text/plain';
 
 	eval {
+		die 'Message-ID too long' if length($mid) > MAX_MID_SIZE;
 		my $smsg = $self->lookup_message($mid);
 		my $doc;
 
@@ -230,6 +232,9 @@ sub link_message_to_parents {
 
 		# prevent circular references via References: here:
 		foreach my $ref (@orig_refs) {
+			if (length($ref) > MAX_MID_SIZE) {
+				warn "References: <$ref> too long, ignoring\n";
+			}
 			next if $uniq{$ref};
 			$uniq{$ref} = 1;
 			push @refs, $ref;
-- 
EW


  parent reply	other threads:[~2015-10-03 11:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-03 11:14 [PATCH 0/4] misc updates Eric Wong
2015-10-03 11:14 ` [PATCH 1/4] nntpd: executable permission Eric Wong
2015-10-03 11:14 ` [PATCH 2/4] rename mid_compress to id_compress Eric Wong
2015-10-03 11:14 ` Eric Wong [this message]
2015-10-03 11:14 ` [PATCH 4/4] mda: support a 'filter=scrub' option for external lists Eric Wong

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=20151003111411.1003-4-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).