[Catalyst-commits] r10296 - in Catalyst-Runtime/5.80/trunk:
lib/Catalyst lib/Catalyst/DispatchType t/aggregate
t/lib/TestApp/Controller/Action
t0m at dev.catalyst.perl.org
t0m at dev.catalyst.perl.org
Tue May 26 18:28:41 GMT 2009
Author: t0m
Date: 2009-05-26 18:28:41 +0000 (Tue, 26 May 2009)
New Revision: 10296
Modified:
Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Chained.pm
Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm
Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_chained.t
Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Chained.pm
Log:
Change to decode args for in chained dispatch.
merge -r 10290:10295 from branches/decode-chained-args
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Chained.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Chained.pm 2009-05-26 18:25:52 UTC (rev 10295)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/DispatchType/Chained.pm 2009-05-26 18:28:41 UTC (rev 10296)
@@ -151,8 +151,14 @@
my @parts = split('/', $path);
my ($chain, $captures, $parts) = $self->recurse_match($c, '/', \@parts);
- push @{$request->args}, @$parts if $parts && @$parts;
+ if ($parts && @$parts) {
+ for my $arg (@$parts) {
+ $arg =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;
+ push @{$request->args}, $arg;
+ }
+ }
+
return 0 unless $chain;
my $action = Catalyst::ActionChain->from_chain($chain);
Modified: Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm 2009-05-26 18:25:52 UTC (rev 10295)
+++ Catalyst-Runtime/5.80/trunk/lib/Catalyst/Request.pm 2009-05-26 18:28:41 UTC (rev 10296)
@@ -219,8 +219,7 @@
and the URI for the request was C<http://.../foo/moose/bah>, the string C<bah>
would be the first and only argument.
-Arguments just get passed through and B<don't> get unescaped automatically, so
-you should do that explicitly.
+Arguments get automatically URI-unescaped for you.
=head2 $req->args
Modified: Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_chained.t
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_chained.t 2009-05-26 18:25:52 UTC (rev 10295)
+++ Catalyst-Runtime/5.80/trunk/t/aggregate/live_component_controller_action_chained.t 2009-05-26 18:28:41 UTC (rev 10296)
@@ -10,7 +10,7 @@
BEGIN { $iters = $ENV{CAT_BENCH_ITERS} || 1; }
-use Test::More tests => 145*$iters;
+use Test::More tests => 147*$iters;
use Catalyst::Test 'TestApp';
if ( $ENV{CAT_BENCHMARK} ) {
@@ -1009,7 +1009,13 @@
ok( my $content =
get('http://localhost/chained/return_arg/foo%2Fbar%3B'),
'request with URI-encoded arg' );
- # this is the CURRENT behavior
- like( $content, qr{foo%2Fbar%3B\z}, 'args NOT decoded' );
+ like( $content, qr{foo/bar;\z}, 'args decoded' );
}
+ {
+ ok( my $content =
+ get('http://localhost/chained/return_arg_decoded/foo%2Fbar%3B'),
+ 'request with URI-encoded arg' );
+ like( $content, qr{foo/bar;\z}, 'args decoded' );
+ }
}
+
Modified: Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Chained.pm
===================================================================
--- Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Chained.pm 2009-05-26 18:25:52 UTC (rev 10295)
+++ Catalyst-Runtime/5.80/trunk/t/lib/TestApp/Controller/Action/Chained.pm 2009-05-26 18:28:41 UTC (rev 10296)
@@ -3,6 +3,8 @@
use strict;
use warnings;
+use HTML::Entities;
+
use base qw/Catalyst::Controller/;
sub begin :Private { }
@@ -196,7 +198,12 @@
sub doc_star : Chained('/') PathPart('chained/doc') Args(1) {}
sub return_arg : Chained('/') PathPart('chained/return_arg') Args(1) {}
+sub return_arg_decoded : Chained('/') PathPart('chained/return_arg_decoded') Args(1) {
+ my ($self, $c) = @_;
+ $c->req->args([ map { decode_entities($_) } @{ $c->req->args }]);
+}
+
sub end :Private {
my ($self, $c) = @_;
return if $c->stash->{no_end};
More information about the Catalyst-commits
mailing list