Skip to content

Commit b7bad82

Browse files
committed
ensure that the retrieved response is always within range of of input.
When some of the 'release' parameter is not recognized as the format of "AUTHOR/DistName-v1.23", it shall be simply ignored as if that parameter simply does not exists. Also, avoid constructing an empty ES query -- which would recall everything.
1 parent 8f52562 commit b7bad82

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lib/MetaCPAN/Server/Controller/Changes.pm

+11-10
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,17 @@ sub all : Chained('index') : PathPart('') : Args(0) {
6868
sub by_releases : Path('by_releases') : Args(0) {
6969
my ( $self, $c ) = @_;
7070

71-
my $ret = $c->model('CPAN::Release')->by_author_and_names([
72-
map {
73-
my @o = split('/', $_, 2);
74-
@o != 2 ? () : (+{
75-
author => $o[0],
76-
name => $o[1],
77-
})
78-
}
79-
@{ $c->read_param("release") }
80-
]);
71+
my @releases = map {
72+
my @o = split( '/', $_, 2 );
73+
@o == 2 ? { author => $o[0], name => $o[1] } : ();
74+
} @{ $c->read_param("release") };
75+
76+
unless (@releases) {
77+
$c->stash( { changes => [] } );
78+
return;
79+
}
80+
81+
my $ret = $c->model('CPAN::Release')->by_author_and_names( \@releases );
8182

8283
my @changes;
8384
for my $release ( @{ $ret->{releases} } ) {

0 commit comments

Comments
 (0)