X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FMID.pm;h=422902f53bed43ab31fff3d93e817adf3d94f441;hb=ae68bf5da734189549bbac3a525845a58e45d77f;hp=96085399b6d2f2d96ba9bef3d06376a953132953;hpb=95bd8265dfb67ba90e7068bf5a4360168a1f30b6;p=public-inbox.git diff --git a/lib/PublicInbox/MID.pm b/lib/PublicInbox/MID.pm index 96085399..422902f5 100644 --- a/lib/PublicInbox/MID.pm +++ b/lib/PublicInbox/MID.pm @@ -10,7 +10,10 @@ our @EXPORT_OK = qw/mid_clean id_compress mid2path mid_mime mid_escape MID_ESC mids references/; use URI::Escape qw(uri_escape_utf8); use Digest::SHA qw/sha1_hex/; -use constant MID_MAX => 40; # SHA-1 hex length +use constant { + MID_MAX => 40, # SHA-1 hex length # TODO: get rid of this + MAX_MID_SIZE => 244, # max term size (Xapian limitation) - length('Q') +}; sub mid_clean { my ($mid) = @_; @@ -61,6 +64,12 @@ sub mids ($) { push(@mids, $v); } } + foreach my $i (0..$#mids) { + next if length($mids[$i]) <= MAX_MID_SIZE; + warn "Message-ID: <$mids[$i]> too long, truncating\n"; + $mids[$i] = substr($mids[$i], 0, MAX_MID_SIZE); + } + uniq_mids(\@mids); }