]> Sergey Matveev's repositories - public-inbox.git/blobdiff - public-inbox.cgi
cgi: avoid parsing ENV directly for PATH_INFO
[public-inbox.git] / public-inbox.cgi
index 6a6f31e23ef81acd8045001190a3e7991c012290..313a4f22e66eae0923191ef9e654e296c79075e5 100755 (executable)
@@ -16,7 +16,7 @@ use CGI qw(:cgi :escapeHTML -nosticky); # PSGI/FastCGI/mod_perl compat
 use Encode qw(decode_utf8);
 use PublicInbox::Config;
 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;
@@ -50,12 +50,12 @@ sub main {
        if ($cgi->request_method !~ /\AGET|HEAD\z/) {
                return r("405 Method Not Allowed");
        }
-       my $path_info = decode_utf8($ENV{PATH_INFO});
+       my $path_info = decode_utf8($cgi->path_info);
 
        # 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/(?:index\.html)?\z!o) {
                invalid_list(\%ctx, $1) || get_index(\%ctx, $cgi, 1);
        } elsif ($path_info =~ m!$LISTNAME_RE/index\.atom\.xml\z!o) {
                invalid_list(\%ctx, $1) || get_atom(\%ctx, $cgi, 1);