]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WWW.pm
switch read-only Email::Simple users to Eml
[public-inbox.git] / lib / PublicInbox / WWW.pm
index 5017f572c8947978e252463afe6df511ee4b9137..1ff857dec0585b81c04dcbf31bb46d2e0f3a4d4f 100644 (file)
@@ -22,6 +22,7 @@ use PublicInbox::MID qw(mid_escape);
 use PublicInbox::GitHTTPBackend;
 use PublicInbox::UserContent;
 use PublicInbox::WwwStatic qw(r path_info_raw);
+use PublicInbox::Eml;
 
 # TODO: consider a routing tree now that we have more endpoints:
 our $INBOX_RE = qr!\A/([\w\-][\w\.\-]*)!;
@@ -125,6 +126,8 @@ sub call {
                get_vcs_object($ctx, $1, $2, $3);
        } elsif ($path_info =~ m!$INBOX_RE/($OID_RE)/s\z!o) {
                r301($ctx, $1, $2, 's/');
+       } elsif ($path_info =~ m!$INBOX_RE/(\w+)\.sql\.gz\z!o) {
+               get_altid_dump($ctx, $1, $2);
        # convenience redirects order matters
        } elsif ($path_info =~ m!$INBOX_RE/([^/]{2,})\z!o) {
                r301($ctx, $1, $2);
@@ -139,6 +142,12 @@ sub call {
 # fragmentation since common allocators favor a large contiguous heap.
 sub preload {
        my ($self) = @_;
+
+       # populate caches used by Encode internally, since emails
+       # may show up with any encoding.
+       require Encode;
+       Encode::find_encoding($_) for Encode->encodings(':all');
+
        require PublicInbox::ExtMsg;
        require PublicInbox::Feed;
        require PublicInbox::View;
@@ -170,6 +179,7 @@ sub preload {
 
 sub preload_inbox {
        my $ibx = shift;
+       $ibx->altid_map;
        $ibx->cloneurl;
        $ibx->description;
        $ibx->base_url;
@@ -222,9 +232,8 @@ sub invalid_inbox_mid {
                my ($x2, $x38) = ($1, $2);
                # this is horrifically wasteful for legacy URLs:
                my $str = $ctx->{-inbox}->msg_by_path("$x2/$x38") or return;
-               require Email::Simple;
-               my $s = Email::Simple->new($str);
-               $mid = PublicInbox::MID::mid_clean($s->header('Message-ID'));
+               my $s = PublicInbox::Eml->new($str);
+               $mid = PublicInbox::MID::mid_clean($s->header_raw('Message-ID'));
                return r301($ctx, $inbox, mid_escape($mid));
        }
        undef;