From: Matt S Trout Date: Sun, 29 Jan 2006 22:55:09 +0000 (+0000) Subject: - Fixed http://dev.catalyst.perl.org/ticket/62 X-Git-Tag: 5.7099_04~720 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=595f3872331fe9d3b2fc22a18a7e03abc1e69d42 - Fixed http://dev.catalyst.perl.org/ticket/62 --- diff --git a/Changes b/Changes index 8ac6770..5dbdec5 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ This file documents the revision history for Perl extension Catalyst. + - Fixed path dispatch to canonicalise correctly + (see http://dev.catalyst.perl.org/ticket/62) + 5.64 - Removed YAML support diff --git a/lib/Catalyst/DispatchType/Path.pm b/lib/Catalyst/DispatchType/Path.pm index 227815f..64bc477 100644 --- a/lib/Catalyst/DispatchType/Path.pm +++ b/lib/Catalyst/DispatchType/Path.pm @@ -3,6 +3,7 @@ package Catalyst::DispatchType::Path; use strict; use base qw/Catalyst::DispatchType/; use Text::SimpleTable; +use URI; =head1 NAME @@ -95,6 +96,7 @@ sub register_path { my ( $self, $c, $path, $action ) = @_; $path =~ s!^/!!; $path = '/' unless length $path; + $path = URI->new($path)->canonical; $self->{paths}{$path} = $action; } diff --git a/lib/Catalyst/Request.pm b/lib/Catalyst/Request.pm index ada6c15..b35bc59 100644 --- a/lib/Catalyst/Request.pm +++ b/lib/Catalyst/Request.pm @@ -365,7 +365,6 @@ sub path { my $path = $self->uri->path; my $location = $self->base->path; $path =~ s/^(\Q$location\E)?//; - $path =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg; $path =~ s/^\///; $self->{path} = $path; diff --git a/t/live_component_controller_action_local.t b/t/live_component_controller_action_local.t index 6a5eefb..70a31e7 100644 --- a/t/live_component_controller_action_local.t +++ b/t/live_component_controller_action_local.t @@ -10,7 +10,7 @@ our $iters; BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 2; } -use Test::More tests => 24*$iters; +use Test::More tests => 30*$iters; use Catalyst::Test 'TestApp'; if ( $ENV{CAT_BENCHMARK} ) { @@ -102,4 +102,26 @@ sub run_tests { 'Content is a serialized Catalyst::Request' ); } + + { + ok( + my $response = + request('http://localhost/action/local/two/foo%2Fbar'), + 'Request' + ); + ok( $response->is_success, 'Response Successful 2xx' ); + is( $response->content_type, 'text/plain', 'Response Content-Type' ); + is( $response->header('X-Catalyst-Action'), + 'action/local/two', 'Test Action' ); + is( + $response->header('X-Test-Class'), + 'TestApp::Controller::Action::Local', + 'Test Class' + ); + like( + $response->content, + qr/arguments => \[\s*'foo%2Fbar'\s*\]/, + "Parameters don't split on %2F" + ); + } } diff --git a/t/live_component_controller_action_path.t b/t/live_component_controller_action_path.t index 52cd73a..96a52cb 100644 --- a/t/live_component_controller_action_path.t +++ b/t/live_component_controller_action_path.t @@ -27,14 +27,14 @@ sub run_tests { { ok( my $response = - request('http://localhost/action/path/a path with spaces'), + request('http://localhost/action/path/a%20path%20with%20spaces'), 'Request' ); ok( $response->is_success, 'Response Successful 2xx' ); is( $response->content_type, 'text/plain', 'Response Content-Type' ); is( $response->header('X-Catalyst-Action'), - 'action/path/a path with spaces', + 'action/path/a%20path%20with%20spaces', 'Test Action' ); is( @@ -55,7 +55,7 @@ sub run_tests { ok( $response->is_success, 'Response Successful 2xx' ); is( $response->content_type, 'text/plain', 'Response Content-Type' ); is( $response->header('X-Catalyst-Action'), - 'action/path/åäö', 'Test Action' ); + 'action/path/%C3%A5%C3%A4%C3%B6', 'Test Action' ); is( $response->header('X-Test-Class'), 'TestApp::Controller::Action::Path',