CGI mounts should probably handle this internally. We're reverting
this since it adds too much potential for abuse with fake/extra
prefixes in the URL. We also need to reorder our redirect handling
as a result.
This reverts commit
c394de9f2c91c2c5ed1f7832a5a7cc0206120b7f.
use PublicInbox::Config;
use URI::Escape qw(uri_escape uri_unescape);
use Digest::SHA qw(sha1_hex);
use PublicInbox::Config;
use URI::Escape qw(uri_escape uri_unescape);
use Digest::SHA qw(sha1_hex);
-our $LISTNAME_RE = qr!\A(?:/.*?)?/([\w\.\-]+)!;
+our $LISTNAME_RE = qr!\A/([\w\.\-]+)!;
our $pi_config;
BEGIN {
$pi_config = PublicInbox::Config->new;
our $pi_config;
BEGIN {
$pi_config = PublicInbox::Config->new;
# top-level indices and feeds
if ($path_info eq "/") {
r404();
# top-level indices and feeds
if ($path_info eq "/") {
r404();
- } elsif ($path_info =~ m!$LISTNAME_RE/(?:index\.html)?\z!o) {
+ } elsif ($path_info =~ m!$LISTNAME_RE\z!o) {
+ invalid_list(\%ctx, $1) || redirect_list_index(\%ctx, $cgi);
+ } elsif ($path_info =~ m!$LISTNAME_RE(?:/|/index\.html)?\z!o) {
invalid_list(\%ctx, $1) || get_index(\%ctx, $cgi, 1);
} elsif ($path_info =~ m!$LISTNAME_RE/(?:all\.html)?\z!o) {
invalid_list(\%ctx, $1) || get_index(\%ctx, $cgi, 0);
invalid_list(\%ctx, $1) || get_index(\%ctx, $cgi, 1);
} elsif ($path_info =~ m!$LISTNAME_RE/(?:all\.html)?\z!o) {
invalid_list(\%ctx, $1) || get_index(\%ctx, $cgi, 0);
} elsif ($path_info =~ m!$LISTNAME_RE/f/(\S+)\z!o) {
redirect_mid_html($cgi, $1, $2);
} elsif ($path_info =~ m!$LISTNAME_RE/f/(\S+)\z!o) {
redirect_mid_html($cgi, $1, $2);
- } elsif ($path_info =~ m!$LISTNAME_RE\z!o) {
- invalid_list(\%ctx, $1) || redirect_list_index(\%ctx, $cgi);
$res = cgi_run("/test/m/blahblah\@example.com.txt");
like($res->{body}, qr/Message-Id: <blahblah\@example\.com>/,
"mid.txt hit");
$res = cgi_run("/test/m/blahblah\@example.com.txt");
like($res->{body}, qr/Message-Id: <blahblah\@example\.com>/,
"mid.txt hit");
-
- my $pfx = cgi_run("/prefixed/test/m/blahblah\@example.com.txt");
- is_deeply($pfx, $res, "we do not have to be a top-level URL");
-
$res = cgi_run("/test/m/blahblah\@example.con.txt");
like($res->{head}, qr/Status: 404 Not Found/, "mid.txt miss");
$res = cgi_run("/test/m/blahblah\@example.con.txt");
like($res->{head}, qr/Status: 404 Not Found/, "mid.txt miss");