From 18dcf6b7103dcd5a28f2c572fcc66965e5885bed Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Sat, 28 Sep 2024 19:25:07 +0200 Subject: [PATCH] add Args(0) to controller actions not expected to recieve args Controller actions without an explicit Arg/Args are treated as having infinite arguments. Add an Args(0) to the routes that are not expected to have sub-paths. --- lib/MetaCPAN/Server/Controller.pm | 2 +- lib/MetaCPAN/Server/Controller/Login.pm | 2 +- lib/MetaCPAN/Server/Controller/Login/GitHub.pm | 2 +- lib/MetaCPAN/Server/Controller/Login/Google.pm | 2 +- lib/MetaCPAN/Server/Controller/Login/PAUSE.pm | 2 +- lib/MetaCPAN/Server/Controller/Login/Twitter.pm | 2 +- lib/MetaCPAN/Server/Controller/Pod.pm | 2 +- lib/MetaCPAN/Server/Controller/Root.pm | 2 +- lib/MetaCPAN/Server/Controller/User.pm | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/MetaCPAN/Server/Controller.pm b/lib/MetaCPAN/Server/Controller.pm index 318a7e9f2..a6affa018 100644 --- a/lib/MetaCPAN/Server/Controller.pm +++ b/lib/MetaCPAN/Server/Controller.pm @@ -52,7 +52,7 @@ sub model { return $model; } -sub mapping : Path('_mapping') { +sub mapping : Path('_mapping') Args(0) { my ( $self, $c ) = @_; $c->stash( $c->model('CPAN')->es->indices->get_mapping( diff --git a/lib/MetaCPAN/Server/Controller/Login.pm b/lib/MetaCPAN/Server/Controller/Login.pm index df13611f8..24555eeed 100644 --- a/lib/MetaCPAN/Server/Controller/Login.pm +++ b/lib/MetaCPAN/Server/Controller/Login.pm @@ -26,7 +26,7 @@ sub auto : Private { return 1; } -sub index : Path { +sub index : Path Args(0) { my ( $self, $c ) = @_; my @login = map { "
  • $_
  • " } sort map /^Login::(.*)/, $c->controllers; diff --git a/lib/MetaCPAN/Server/Controller/Login/GitHub.pm b/lib/MetaCPAN/Server/Controller/Login/GitHub.pm index d7b697b10..e8f9de160 100644 --- a/lib/MetaCPAN/Server/Controller/Login/GitHub.pm +++ b/lib/MetaCPAN/Server/Controller/Login/GitHub.pm @@ -13,7 +13,7 @@ has [qw(consumer_key consumer_secret)] => ( required => 1, ); -sub index : Path { +sub index : Path Args(0) { my ( $self, $c ) = @_; if ( my $code = $c->req->params->{code} ) { my $ua = LWP::UserAgent->new; diff --git a/lib/MetaCPAN/Server/Controller/Login/Google.pm b/lib/MetaCPAN/Server/Controller/Login/Google.pm index f7cd9f498..6d3edf29d 100644 --- a/lib/MetaCPAN/Server/Controller/Login/Google.pm +++ b/lib/MetaCPAN/Server/Controller/Login/Google.pm @@ -15,7 +15,7 @@ has [qw( consumer_key consumer_secret )] => ( required => 1, ); -sub index : Path { +sub index : Path Args(0) { my ( $self, $c ) = @_; my $req = $c->req; diff --git a/lib/MetaCPAN/Server/Controller/Login/PAUSE.pm b/lib/MetaCPAN/Server/Controller/Login/PAUSE.pm index 3f8aeb9d7..c96ac2262 100644 --- a/lib/MetaCPAN/Server/Controller/Login/PAUSE.pm +++ b/lib/MetaCPAN/Server/Controller/Login/PAUSE.pm @@ -23,7 +23,7 @@ sub _build_cache { ); } -sub index : Path { +sub index : Path Args(0) { my ( $self, $c ) = @_; my $code = $c->req->params->{code}; my $id; diff --git a/lib/MetaCPAN/Server/Controller/Login/Twitter.pm b/lib/MetaCPAN/Server/Controller/Login/Twitter.pm index d8f2ed4fd..2bb917f61 100644 --- a/lib/MetaCPAN/Server/Controller/Login/Twitter.pm +++ b/lib/MetaCPAN/Server/Controller/Login/Twitter.pm @@ -20,7 +20,7 @@ sub nt { ); } -sub index : Path { +sub index : Path Args(0) { my ( $self, $c ) = @_; my $req = $c->req; diff --git a/lib/MetaCPAN/Server/Controller/Pod.pm b/lib/MetaCPAN/Server/Controller/Pod.pm index 228bea17b..4ee619714 100644 --- a/lib/MetaCPAN/Server/Controller/Pod.pm +++ b/lib/MetaCPAN/Server/Controller/Pod.pm @@ -77,7 +77,7 @@ sub find_dist_links { return $links; } -sub render : Path('/pod_render') { +sub render : Path('/pod_render') Args(0) { my ( $self, $c ) = @_; my $pod = $c->req->parameters->{pod}; my $show_errors = !!$c->req->parameters->{show_errors}; diff --git a/lib/MetaCPAN/Server/Controller/Root.pm b/lib/MetaCPAN/Server/Controller/Root.pm index 00cb25b4e..d0fb311bf 100644 --- a/lib/MetaCPAN/Server/Controller/Root.pm +++ b/lib/MetaCPAN/Server/Controller/Root.pm @@ -62,7 +62,7 @@ sub bad_request : Private { $c->forward( $c->view('JSON') ); } -sub robots : Path("robots.txt") { +sub robots : Path("robots.txt") Args(0) { my ( $self, $c ) = @_; $c->res->content_type("text/plain"); $c->res->body("User-agent: *\nDisallow: /\n"); diff --git a/lib/MetaCPAN/Server/Controller/User.pm b/lib/MetaCPAN/Server/Controller/User.pm index 8a84a76d3..1d3ae9bb7 100644 --- a/lib/MetaCPAN/Server/Controller/User.pm +++ b/lib/MetaCPAN/Server/Controller/User.pm @@ -31,7 +31,7 @@ sub auto : Private { return $c->user_exists; } -sub index : Path { +sub index : Path Args(0) { my ( $self, $c ) = @_; $c->stash( $c->user->data ); delete $c->stash->{code};