]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwListing.pm
www: avoid potential auto-vivification on ibx->{url}
[public-inbox.git] / lib / PublicInbox / WwwListing.pm
index eabda98abe484bebc0ff41276de648e91675f8bc..ef9048b5be925f77ab20377a049171aa4f4f47ad 100644 (file)
@@ -17,7 +17,7 @@ sub ibx_entry {
        my $desc = ascii_html($ce->{description} //= $ibx->description);
        my $ts = fmt_ts($ce->{-modified} //= $ibx->modified);
        my ($url, $href);
-       if (defined($ibx->{url})) {
+       if (scalar(@{$ibx->{url} // []})) {
                $url = $href = ascii_html(prurl($ctx->{env}, $ibx->{url}));
        } else {
                $href = ascii_html(uri_escape_utf8($ibx->{name})) . '/';
@@ -41,7 +41,7 @@ sub list_match_i { # ConfigIter callback
                return if $section !~ m!\Apublicinbox\.([^/]+)\z!;
                my $ibx = $cfg->lookup_name($1) or return;
                if (!$ibx->{-hide}->{$ctx->hide_key} &&
-                                       grep(/$re/, @{$ibx->{url}})) {
+                                       grep(/$re/, @{$ibx->{url} // []})) {
                        $ctx->ibx_entry($ibx);
                }
        } else { # undef == "EOF"
@@ -96,7 +96,8 @@ sub add_misc_ibx { # MiscSearch->retry_reopen callback
 
        delete $ctx->{-list}; # reset if retried
        my $pi_cfg = $ctx->{www}->{pi_cfg};
-       if (defined(my $user_query = $q->{'q'})) {
+       my $user_query = $q->{'q'} // '';
+       if ($user_query =~ /\S/) {
                $qs = "( $qs ) AND ( $user_query )";
        } else { # special case for ALL
                $ctx->ibx_entry($pi_cfg->ALL // die('BUG: ->ALL expected'), {});
@@ -218,6 +219,10 @@ sub psgi_triple {
                $gzf->zmore('<pre>');
                $gzf->zmore(join("\n", @$list));
                $gzf->zmore(mset_footer($ctx, $mset)) if $mset;
+       } elsif (my $mset = delete $ctx->{-mset}) {
+               $gzf->zmore(mset_nav_top($ctx, $mset));
+               $gzf->zmore('<pre>no matching inboxes');
+               $gzf->zmore(mset_footer($ctx, $mset));
        } else {
                $gzf->zmore('<pre>no inboxes, yet');
        }