- Fixed http://dev.catalyst.perl.org/ticket/62
Matt S Trout [Sun, 29 Jan 2006 22:55:09 +0000 (22:55 +0000)]
Changes
lib/Catalyst/DispatchType/Path.pm
lib/Catalyst/Request.pm
t/live_component_controller_action_local.t
t/live_component_controller_action_path.t

diff --git a/Changes b/Changes
index 8ac6770..5dbdec5 100644 (file)
--- 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
 
index 227815f..64bc477 100644 (file)
@@ -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;
 }
 
index ada6c15..b35bc59 100644 (file)
@@ -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;
 
index 6a5eefb..70a31e7 100644 (file)
@@ -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"
+        );
+    }
 }
index 52cd73a..96a52cb 100644 (file)
@@ -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',