my $ctx = { env => $env, www => $self };
# we don't care about multi-value
- my %qp = map {
+ %{$ctx->{qp}} = map {
utf8::decode($_);
- my ($k, $v) = split('=', uri_unescape($_), 2);
- $v = '' unless defined $v;
- $v =~ tr/+/ /;
- ($k, $v)
+ tr/+/ /;
+ my ($k, $v) = split('=', $_, 2);
+ $v = uri_unescape($v // '');
+ # none of the keys we care about will need escaping
+ $k => $v;
} split(/[&;]+/, $env->{QUERY_STRING});
- $ctx->{qp} = \%qp;
- # not using $env->{PATH_INFO} here since that's already decoded
+ # avoiding $env->{PATH_INFO} here since that's already decoded
my ($path_info) = ($env->{REQUEST_URI} =~ path_re($env));
+ $path_info //= $env->{PATH_INFO};
my $method = $env->{REQUEST_METHOD};
if ($method eq 'POST') {
# top-level indices and feeds
if ($path_info eq '/') {
- r404();
+ www_listing($self)->call($env);
} elsif ($path_info =~ m!$INBOX_RE\z!o) {
invalid_inbox($ctx, $1) || r301($ctx, $1);
} elsif ($path_info =~ m!$INBOX_RE(?:/|/index\.html)?\z!o) {
if (ref($self)) {
$self->cgit;
$self->stylesheets_prepare($_) for ('', '../', '../../');
+ $self->www_listing;
}
}
}
}
+sub www_listing {
+ my ($self) = @_;
+ $self->{www_listing} ||= do {
+ require PublicInbox::WwwListing;
+ PublicInbox::WwwListing->new($self);
+ }
+}
+
sub get_attach {
my ($ctx, $idx, $fn) = @_;
require PublicInbox::WwwAttach;