]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WWW.pm
www: loosen deep-linking prevention
[public-inbox.git] / lib / PublicInbox / WWW.pm
index a7c961f4982a962c43071035660c90ed3a697d0a..755d75585df22a18ab495d844705fd075cf57f45 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Main web interface for mailing list archives
@@ -64,6 +64,10 @@ sub call {
                                serve_git($ctx, $epoch, $path);
                } elsif ($path_info =~ m!$INBOX_RE/(\w+)\.sql\.gz\z!o) {
                        return get_altid_dump($ctx, $1, $2);
+               } elsif ($path_info =~ m!$INBOX_RE/$MID_RE/$ATTACH_RE\z!o) {
+                       my ($idx, $fn) = ($3, $4);
+                       return invalid_inbox_mid($ctx, $1, $2) ||
+                               get_attach($ctx, $idx, $fn);
                } elsif ($path_info =~ m!$INBOX_RE/!o) {
                        return invalid_inbox($ctx, $1) || mbox_results($ctx);
                }
@@ -170,21 +174,13 @@ sub preload {
                if (defined($pi_cfg->{'publicinbox.cgitrc'})) {
                        $pi_cfg->limiter('-cgit');
                }
+               $pi_cfg->ALL and require PublicInbox::Isearch;
                $self->cgit;
                $self->stylesheets_prepare($_) for ('', '../', '../../');
                $self->news_www;
-               $pi_cfg->each_inbox(\&preload_inbox);
        }
 }
 
-sub preload_inbox {
-       my $ibx = shift;
-       $ibx->altid_map;
-       $ibx->cloneurl;
-       $ibx->description;
-       $ibx->base_url;
-}
-
 # private functions below
 
 sub r404 {
@@ -476,7 +472,7 @@ sub serve_mbox_range {
 
 sub news_www {
        my ($self) = @_;
-       $self->{news_www} ||= do {
+       $self->{news_www} //= do {
                require PublicInbox::NewsWWW;
                PublicInbox::NewsWWW->new($self->{pi_cfg});
        }
@@ -484,7 +480,7 @@ sub news_www {
 
 sub cgit {
        my ($self) = @_;
-       $self->{cgit} ||= do {
+       $self->{cgit} //= do {
                my $pi_cfg = $self->{pi_cfg};
 
                if (defined($pi_cfg->{'publicinbox.cgitrc'})) {