Skip to content

Commit

Permalink
fixed bug where not all uppercase methods were hidden from the router
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 3, 2013
1 parent 31f1846 commit 5a39293
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,7 +1,8 @@

4.17 2013-07-01
4.17 2013-07-03
- Fixed Mojo::Transaction::WebSocket to generate RFC 6455 compliant
Sec-WebSocket-Key headers. (josh)
- Fixed bug where not all uppercase methods were hidden from the router.

4.16 2013-06-19
- Improved Perl 5.10.x and 5.12.x compatibility. (trinitum)
Expand Down
9 changes: 4 additions & 5 deletions lib/Mojolicious.pm
Expand Up @@ -69,11 +69,10 @@ sub new {
my $r = $self->routes->namespaces([ref $self]);

# Hide controller attributes/methods and "handler"
$r->hide(qw(AUTOLOAD DESTROY app cookie finish flash handler match on));
$r->hide(qw(param redirect_to render render_exception render_later));
$r->hide(qw(render_maybe render_not_found render_static rendered req res));
$r->hide(qw(respond_to send session signed_cookie stash tx url_for write));
$r->hide(qw(write_chunk));
$r->hide(qw(app cookie finish flash handler match on param redirect_to));
$r->hide(qw(render render_exception render_later render_maybe));
$r->hide(qw(render_not_found render_static rendered req res respond_to));
$r->hide(qw(send session signed_cookie stash tx url_for write write_chunk));

# Check if we have a log directory
my $mode = $self->mode;
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojolicious/Routes.pm
Expand Up @@ -68,8 +68,8 @@ sub hide { push @{shift->hidden}, @_ }

sub is_hidden {
my ($self, $method) = @_;
my $hiding = $self->{hiding} ||= {map { $_ => 1 } @{$self->hidden}};
return !!($hiding->{$method} || index($method, '_') == 0);
my $h = $self->{hiding} ||= {map { $_ => 1 } @{$self->hidden}};
return !!($h->{$method} || index($method, '_') == 0 || $method !~ /[a-z]/);
}

sub lookup {
Expand Down
1 change: 1 addition & 0 deletions t/mojolicious/app.t
Expand Up @@ -68,6 +68,7 @@ ok $t->app->routes->is_hidden('bar'), 'is hidden';
ok $t->app->routes->is_hidden('_foo'), 'is hidden';
ok $t->app->routes->is_hidden('AUTOLOAD'), 'is hidden';
ok $t->app->routes->is_hidden('DESTROY'), 'is hidden';
ok $t->app->routes->is_hidden('FOO_BAR'), 'is hidden';
ok $t->app->routes->is_hidden('app'), 'is hidden';
ok $t->app->routes->is_hidden('attr'), 'is hidden';
ok $t->app->routes->is_hidden('cookie'), 'is hidden';
Expand Down

0 comments on commit 5a39293

Please sign in to comment.