Skip to content

Commit 30e74ff

Browse files
authored
Merge pull request #3086 from metacpan/haarg/fix-warnings
Fix some common warnings/errors shown in the logs.
2 parents 34af3b8 + 6dfc7db commit 30e74ff

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

lib/MetaCPAN/Web/Controller/Dist.pm

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ BEGIN { extends 'MetaCPAN::Web::Controller' }
77

88
sub root : Chained('/') PathPart('dist') CaptureArgs(1) {
99
my ( $self, $c, $dist ) = @_;
10+
if ( $dist =~ /[^A-Za-z0-9_\-\.\@\+]/ ) {
11+
$c->detach('/not_found');
12+
}
1013
$c->stash( { distribution_name => $dist } );
1114
}
1215

root/diff.tx

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
</li>
3838
%% }
3939
<li class="nav-header">Info</li>
40-
<li>[% pluralize("%d insertion(s)", $diff.statistics.map(-> $f { $f.insertions }).sum()) %]</li>
41-
<li>[% pluralize("%d deletion(s)", $diff.statistics.map(-> $f { $f.deletions }).sum()) %]</li>
40+
<li>[% pluralize("%d insertion(s)", $diff.statistics.map(-> $f { $f.insertions }).grep(rx('^\d+$')).sum()) %]</li>
41+
<li>[% pluralize("%d deletion(s)", $diff.statistics.map(-> $f { $f.deletions }).grep(rx('^\d+$')).sum()) %]</li>
4242
<li><div><a href="#">Top</a></div></li>
4343
%% }
4444
%% override content -> {
@@ -51,7 +51,7 @@
5151
%% }
5252
<tr>
5353
<td>[% pluralize("%s file(s)", $diff.statistics.size()) %] changed (This is a [% $diff.source.file ? 'file' : 'version' %] diff)</td>
54-
<td><span class="minus">[% $diff.statistics.map(-> $f { $f.deletions }).sum() %]</span><span class="plus">[% $diff.statistics.map(-> $f { $f.insertions }).sum() %]</span></td>
54+
<td><span class="minus">[% $diff.statistics.map(-> $f { $f.deletions }).grep(rx('^\d+$')).sum() %]</span><span class="plus">[% $diff.statistics.map(-> $f { $f.insertions }).grep(rx('^\d+$')).sum() %]</span></td>
5555
</tr>
5656
</table>
5757

t/controller/release.t

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ test_psgi app, sub {
1111
ok( my $res = $cb->( GET '/dist/DOESNTEXIST' ), 'GET /dist/DOESNTEXIST' );
1212
is( $res->code, 404, 'code 404' );
1313

14+
ok( $res = $cb->( GET '/dist/$$$$' ), 'GET /dist/$$$$' );
15+
is( $res->code, 404, 'code 404' );
16+
1417
ok( $res = $cb->( GET '/release/AUTHORDOESNTEXIST/DOESNTEXIST' ),
1518
'GET /release/AUTHORDOESNTEXIST/DOESNTEXIST' );
1619
is( $res->code, 404, 'code 404' );

0 commit comments

Comments
 (0)