From 0b1c6867ee10d9edcbd75c359cb23c75b732682e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 27 May 2016 08:57:42 +0000 Subject: config: fix NewsWWW fallback for newsgroups in HTTP URLs Oops, added a test to prevent regressions while we're at it. --- lib/PublicInbox/Config.pm | 4 +++- lib/PublicInbox/NewsWWW.pm | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index 935b0445..35b24af4 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -56,7 +56,8 @@ sub lookup_name { my ($self, $name) = @_; my $rv = $self->{-by_name}->{$name}; return $rv if $rv; - $self->{-by_name}->{$name} = _fill($self, "publicinbox.$name"); + $rv = _fill($self, "publicinbox.$name") or return; + $self->{-by_name}->{$name} = $rv; } sub get { @@ -118,6 +119,7 @@ sub _fill { my $v = $self->{"$pfx.$k"}; $rv->{$k} = $v if defined $v; } + return unless $rv->{mainrepo}; my $inbox = $pfx; $inbox =~ s/\Apublicinbox\.//; $rv->{name} = $inbox; diff --git a/lib/PublicInbox/NewsWWW.pm b/lib/PublicInbox/NewsWWW.pm index 19eb596c..5357059d 100644 --- a/lib/PublicInbox/NewsWWW.pm +++ b/lib/PublicInbox/NewsWWW.pm @@ -30,7 +30,6 @@ sub call { if (my $info = $ng_map->{$ng}) { my $url = PublicInbox::Hval::prurl($env, $info->{url}); my $code = 301; - my $h = [ Location => $url, 'Content-Type' => 'text/plain' ]; if (defined $article && $article =~ /\A\d+\z/) { my $mid = eval { ng_mid_for($ng, $info, $article) }; if (defined $mid) { @@ -41,6 +40,8 @@ sub call { } } + my $h = [ Location => $url, 'Content-Type' => 'text/plain' ]; + return [ $code, $h, [ "Redirecting to $url\n" ] ] } [ 404, [ 'Content-Type' => 'text/plain' ], [] ]; -- cgit v1.2.3-24-ge0c7