X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=blobdiff_plain;f=lib%2FPublicInbox%2FMID.pm;h=dddde092f2581ea1d54b1749804642dbccf89a48;hp=d2bbaec71e9ef8b86b35d5f6e54e27da78b9d6fb;hb=906393b801050e303d2ec2a660c85de4a5fa4740;hpb=eaa56562a0a09d9e8ecf3f2371dda20645bd82f3 diff --git a/lib/PublicInbox/MID.pm b/lib/PublicInbox/MID.pm index d2bbaec7..dddde092 100644 --- a/lib/PublicInbox/MID.pm +++ b/lib/PublicInbox/MID.pm @@ -6,8 +6,8 @@ package PublicInbox::MID; use strict; use warnings; use base qw/Exporter/; -our @EXPORT_OK = qw/mid_clean id_compress mid2path mid_mime mid_escape MID_ESC - mids references mids_for_index/; +our @EXPORT_OK = qw(mid_clean id_compress mid2path mid_mime mid_escape MID_ESC + mids references mids_for_index $MID_EXTRACT); use URI::Escape qw(uri_escape_utf8); use Digest::SHA qw/sha1_hex/; require PublicInbox::Address; @@ -16,11 +16,13 @@ use constant { MAX_MID_SIZE => 244, # max term size (Xapian limitation) - length('Q') }; +our $MID_EXTRACT = qr/<([^>]+)>/s; + sub mid_clean { my ($mid) = @_; defined($mid) or die "no Message-ID"; # MDA->precheck did more checking for us - if ($mid =~ /<([^>]+)>/) { + if ($mid =~ $MID_EXTRACT) { $mid = $1; } $mid; @@ -58,7 +60,7 @@ sub mid_mime ($) { mids($_[0]->header_obj)->[0] } sub extract_mids { my @mids; for my $v (@_) { - my @cur = ($v =~ /<([^>]+)>/sg); + my @cur = ($v =~ /$MID_EXTRACT/g); if (@cur) { push(@mids, @cur); } else { @@ -92,7 +94,7 @@ sub references ($) { foreach my $f (qw(References In-Reply-To)) { my @v = $hdr->header_raw($f); foreach my $v (@v) { - push(@mids, ($v =~ /<([^>]+)>/sg)); + push(@mids, ($v =~ /$MID_EXTRACT/g)); } }