]> Sergey Matveev's repositories - public-inbox.git/blobdiff - public-inbox.cgi
cgi: include HTTP status in error message body
[public-inbox.git] / public-inbox.cgi
index 1fb96e75d82aaf9493a6d112001b0e8c765a84d8..bd592ce3e3107c6ed77ea51f0cf0c761284393e4 100755 (executable)
@@ -17,7 +17,7 @@ use Encode qw(decode_utf8);
 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;
@@ -62,7 +62,9 @@ sub main {
        # 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);
@@ -85,8 +87,6 @@ sub main {
        } 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);
        } else {
                r404();
        }
@@ -95,7 +95,7 @@ sub main {
 sub r404 { r("404 Not Found") }
 
 # simple response for errors
-sub r { [ $_[0], { 'Content-Type' => 'text/plain' }, '' ] }
+sub r { [ $_[0], { 'Content-Type' => 'text/plain' }, $_[0]."\n" ] }
 
 # returns undef if valid, array ref response if invalid
 sub invalid_list {